yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
91.84k stars 7.15k forks source link

[Twitch] Wrong error message if stream requires subscription #2856

Open raffaem opened 2 years ago

raffaem commented 2 years ago

Checklist

Region

Italy

Description

The Twitch stream fails to download if it requires subscription.

The output says:

report this issue on https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template

and doesn't allow me to insert login and password for the user who is subscribed to the channel.

Verbose log

$ yt-dlp -vU https://www.twitch.tv/videos/1305275390
[debug] Command-line config: ['-vU', 'https://www.twitch.tv/videos/1305275390']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.02.04 [c1653e9ef]
[debug] Python version 3.10.2 (CPython 64bit) - Linux-5.16.9-200.fc35.x86_64-x86_64-with-glibc2.34
[debug] exe versions: ffmpeg 4.4.1 (setts), ffprobe 4.4.1
[debug] Optional libraries: Cryptodome, secretstorage, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.02.04, Current version: 2022.02.04
yt-dlp is up to date (2022.02.04)
[debug] [twitch:vod] Extracting URL: https://www.twitch.tv/videos/1305275390
[twitch:vod] 1305275390: Downloading stream metadata GraphQL
[twitch:vod] 1305275390: Downloading video access token GraphQL
[twitch:vod] 1305275390: Downloading m3u8 information
ERROR: [twitch:vod] 1305275390: Failed to download m3u8 information: HTTP Error 403: Forbidden (caused by <HTTPError 403: 'Forbidden'>); please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using -U (caused by <HTTPError 403: 'Forbidden'>); please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using -U
  File "/home/raffaele/.local/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 730, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/home/raffaele/.local/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 3558, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib64/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib64/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib64/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
pukkandan commented 2 years ago

yt-dlp can't bypass paywalls. If you have access to the video, pass cookies (and show verbose log with it)

raffaem commented 2 years ago

yt-dlp can't bypass paywalls. If you have access to the video, pass cookies (and show verbose log with it)

Fine, but then the error message should say to pass cookies to it, not to report it as a bug

pukkandan commented 2 years ago
  • [X] I've checked that all provided URLs are alive and playable in a browser
pukkandan commented 2 years ago

then the error message should say to pass cookies to it, not to report it as a bug

It does not seem possible to differentiate (from the API) b/w actually being unable to extract formats and the video being private

hanacchi commented 1 year ago

It does not seem possible to differentiate (from the API) b/w actually being unable to extract formats and the video being private

I think the relevant information is contained in the value field of the access token:

https://github.com/yt-dlp/yt-dlp/blob/5424dbaf91728aaf77458e68d993ba6c34e8e222/yt_dlp/extractor/twitch.py#L518

{'value': '{"authorization":{"forbidden":false,"reason":""},"chansub":{"restricted_bitrates":["160p30","360p30","480p30","720p60","audio_only","chunked"]},"device_id":null,"expires":xxx,"https_required":true,"privileged":false,"user_id":null,"version":2,"vod_id":xxx}', 'signature': 'xxx'}

specifically this part

"chansub":{"restricted_bitrates":["160p30","360p30","480p30","720p60","audio_only","chunked"]}

I'm not sure if it's possible for only some bitrates to be restricted, so downloading the m3u8 still should be attempted in this case. But I think this information can be used to print a more helpful error message.