HoloArchivists / twspace-dl

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

Twitter API change again? #94

Closed mikelei8291 closed 1 year ago

mikelei8291 commented 1 year ago

Describe the bug Run twspace_dl to download Twitter Spaces. I tried both recorded and not recorded + master playlist URL, and none of them worked.

To Reproduce

twspace_dl -i https://twitter.com/i/spaces/1yNGaNYzVdXJj -v

Expected behavior No exception raised and Twitter Space downloaded.

Output If applicable, add the output of the command to help explain your problem.

2023-07-01 18:14:12,867 [DEBUG] Starting new HTTPS connection (1): twitter.com:443
2023-07-01 18:14:13,074 [DEBUG] https://twitter.com:443 "GET /i/api/graphql/jyQ0_DEMZHeoluCgHJ-U5Q/AudioSpaceById?variables=%7B%22id%22%3A%221yNGaNYzVdXJj%22%2C%22isMetatagsQuery%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withUserResults%22%3Atrue%2C%22withBirdwatchPivots%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withReplays%22%3Atrue%2C%22withScheduledSpaces%22%3Atrue%7D HTTP/1.1" 404 0
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/twspace_dl", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/twspace_dl/__main__.py", line 238, in main
    args.func(args)
  File "/usr/local/lib/python3.11/dist-packages/twspace_dl/__main__.py", line 90, in space
    twspace = Twspace.from_space_url(args.input_url)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/twspace_dl/twspace.py", line 184, in from_space_url
    return cls(cls._metadata(space_id))
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/twspace_dl/twspace.py", line 96, in _metadata
    metadata = response.json()
               ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Desktop (please complete the following information):

Additional context The program worked fine so far since the last fix of Twitter API change in #80, but it stopped working again yesterday and I think it was due to Twitter API change.

I'm opening this issue to indication that this is a known issue and no more issue should be opened regard this. I'm going to fix this but if anyone would like to fix it please post below so we don't waste our time doing the same work.

Ryu1845 commented 1 year ago

Hi, thanks for the bug report! Unfortunately, I'm on vacation right now and can't work on it. Feel free to open a pr and I'll review it