ihabunek / twitch-dl

CLI tool for downloading videos from Twitch.
GNU General Public License v3.0
664 stars 83 forks source link

httpx.HTTPStatusError: Client error '403 Forbidden' #144

Closed bryanquatremare closed 10 months ago

bryanquatremare commented 10 months ago

Hi !

I've been using twitch-dl for a long time and never had any problem, until today.

I tried downloading a VOD but it gave me an error 403:

pliplouf@VPS:~$ twitch-dl download https://www.twitch.tv/videos/2021711821
Looking up video...
Found: LE DERNIER LIVE LAYTON AVANT 2025 | LAYTON X PHOENIX WRIGHT VENEZ TOUT DE SUITE by AntoineDaniel
Output: 2024-01-03_2021711821_antoinedaniel_le_dernier_live_layton_avant_2025_layton_x_phoenix_wright_venez_tout_de_suite.mkv
Fetching access token...
Fetching playlists...
Traceback (most recent call last):
  File "/home/pliplouf/.local/bin/twitch-dl", line 8, in <module>
    sys.exit(main())
  File "/home/pliplouf/.local/lib/python3.9/site-packages/twitchdl/console.py", line 321, in main
    args.func(args)
  File "/home/pliplouf/.local/lib/python3.9/site-packages/twitchdl/commands/download.py", line 170, in download
    download_one(video_id, args)
  File "/home/pliplouf/.local/lib/python3.9/site-packages/twitchdl/commands/download.py", line 176, in download_one
    return _download_video(video_id, args)
  File "/home/pliplouf/.local/lib/python3.9/site-packages/twitchdl/commands/download.py", line 292, in _download_video
    playlists_m3u8 = twitch.get_playlists(video_id, access_token)
  File "/home/pliplouf/.local/lib/python3.9/site-packages/twitchdl/twitch.py", line 347, in get_playlists
    response.raise_for_status()
  File "/home/pliplouf/.local/lib/python3.9/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '403 Forbidden' for url 'http://usher.ttvnw.net/vod/2021711821?nauth=%7B%22authorization%22%3A%7B%22forbidden%22%3Afalse%2C%22reason%22%3A%22%22%7D%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22device_id%22%3Anull%2C%22expires%22%3A1704612770%2C%22https_required%22%3Atrue%2C%22privileged%22%3Afalse%2C%22user_id%22%3Anull%2C%22version%22%3A2%2C%22vod_id%22%3A2021711821%7D&nauthsig=301c5af08db024a756822bb087ecc635006c2b36&allow_audio_only=true&allow_source=true&player=twitchweb'
For more information check: https://httpstatuses.com/403

I tried with several videos and channels but I always get the same error.

I've seen on another project that the Twitch API have changed, the modified code is not huge so I don't think this is a big issue 😊

Thank you for your work !

ihabunek commented 10 months ago

Fix released in v2.1.4. Thanks @deanpcmad and @bryanquatremare.