HoloArchivists / twspace-dl

A python module to download twitter spaces.
GNU General Public License v2.0
473 stars 78 forks source link

An exception will be thrown if DynamicURL or MasterURL is specified. #53

Closed migimigi closed 2 years ago

migimigi commented 2 years ago

Describe the bug An exception will be thrown if DynamicURL or MasterURL is specified.

To Reproduce DynamicURL

$ twspace_dl -d 'https://prod-fastly-ap-northeast-1.video.pscp.tv/Transcoding/v1/hls/****/non_transcode/ap-northeast-1/periscope-replay-direct-prod-ap-northeast-1-public/audio-space/playlist_****.m3u8?type=replay'
Traceback (most recent call last):
  File "/opt/homebrew/bin/twspace_dl", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/twspace_dl/__main__.py", line 203, in main
    args.func(args)
  File "/opt/homebrew/lib/python3.10/site-packages/twspace_dl/__main__.py", line 72, in space
    twspace = Twspace.from_space_url(args.input_url)
  File "/opt/homebrew/lib/python3.10/site-packages/twspace_dl/twspace.py", line 169, in from_space_url
    space_id = re.findall(r"(?<=spaces/)\w*", url)[0]
  File "/opt/homebrew/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/re.py", line 240, in findall
    return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object

MasterURL

$ twspace_dl -f 'https://prod-fastly-ap-northeast-1.video.pscp.tv/Transcoding/v1/hls/****/non_transcode/ap-northeast-1/periscope-replay-direct-prod-ap-northeast-1-public/audio-space/master_playlist.m3u8'
Traceback (most recent call last):
  File "/opt/homebrew/bin/twspace_dl", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/twspace_dl/__main__.py", line 203, in main
    args.func(args)
  File "/opt/homebrew/lib/python3.10/site-packages/twspace_dl/__main__.py", line 72, in space
    twspace = Twspace.from_space_url(args.input_url)
  File "/opt/homebrew/lib/python3.10/site-packages/twspace_dl/twspace.py", line 169, in from_space_url
    space_id = re.findall(r"(?<=spaces/)\w*", url)[0]
  File "/opt/homebrew/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/re.py", line 240, in findall
    return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object

Expected behavior

Can be downloaded successfully by specifying DynamicURL or MasterURL.

Describe alternatives you've considered

Since this ability to specify DynamicURL and MasterURL does not appear to be used, I suggest that it be removed. I will explain why I thought the function to specify them was not being used. https://github.com/HoloArchivists/twspace-dl/blob/c3552d331dec46a2259f1a7f0b67043c501ca3dd/twspace_dl/__main__.py#L71-L78

Reading the source code, one can see that the TwspaceDL class is called before DynamicURL and MasterURL are checked.

https://github.com/HoloArchivists/twspace-dl/blob/c3552d331dec46a2259f1a7f0b67043c501ca3dd/twspace_dl/twspace_dl.py#L32-L70

Also, twspace_dl.dyn_url and twspace_dl.master_url are cached_property, so setters cannot be created.

Desktop (please complete the following information):

Ryu1845 commented 2 years ago

That is #52. Closed as duplicate

Ryu1845 commented 2 years ago

The master url and dynamic url can be used with a space url if a space has ended given you provide both the space url and the dynamic / master url