Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Unable to extract yt initial data on playlist #32499

Open
5 of 6 tasks
Fabian200703 opened this issue Aug 11, 2023 · 45 comments · Fixed by #32638
Open
5 of 6 tasks

ERROR: Unable to extract yt initial data on playlist #32499

Fabian200703 opened this issue Aug 11, 2023 · 45 comments · Fixed by #32638
Labels
broken-IE problem with existing site extraction fixed

Comments

@Fabian200703
Copy link

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2021.12.17
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

PASTE VERBOSE LOG HERE

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '-x', 'https://youtube.com/playlist?list=PLA_zjX3swAf5tsw9KdHOGodzcJ_PptL9a']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.8.10 (CPython) - Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.29
[debug] exe versions: none
[debug] Proxy map: {}
[youtube:tab] PLA_zjX3swAf5tsw9KdHOGodzcJ_PptL9a: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/youtube_dl/YoutubeDL.py", line 836, in __extract_info
ie_result = ie.extract(url)
File "/usr/local/lib/python3.8/dist-packages/youtube_dl/extractor/common.py", line 534, in extract
ie_result = self._real_extract(url)
File "/usr/local/lib/python3.8/dist-packages/youtube_dl/extractor/youtube.py", line 2841, in _real_extract
data = self._extract_yt_initial_data(item_id, webpage)
File "/usr/local/lib/python3.8/dist-packages/youtube_dl/extractor/youtube.py", line 299, in _extract_yt_initial_data
self._search_regex(
File "/usr/local/lib/python3.8/dist-packages/youtube_dl/extractor/common.py", line 1012, in _search_regex
raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Description

WRITE DESCRIPTION HERE

as you can see above the program fails to download even a single video from the playlist
i was using the minimum of arguments in the command and trying the same command with single videos from the playlist produces a different error: "ERROR: Unable to extract uploader id;" this seems to be consistent across the entire playlist

@Fabian200703
Copy link
Author

this happens on the nightly build:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '-x', 'https://youtube.com/playlist?list=PLA_zjX3swAf5tsw9KdHOGodzcJ_PptL9a']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2023.08.07 [86e3cf5] (single file build)
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 3.4.4 (CPython AMD64 32bit) - Windows-10-10.0.22621 - OpenSSL 1.0.2d 9 Jul 2015
[debug] exe versions: none
[debug] Proxy map: {}
[youtube:tab] PLA_zjX3swAf5tsw9KdHOGodzcJ_PptL9a: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "D:\a\ytdl-nightly\ytdl-nightly\youtube_dl\YoutubeDL.py", line 863, in wrapper
File "D:\a\ytdl-nightly\ytdl-nightly\youtube_dl\YoutubeDL.py", line 959, in __extract_info
File "D:\a\ytdl-nightly\ytdl-nightly\youtube_dl\extractor\common.py", line 565, in extract
File "D:\a\ytdl-nightly\ytdl-nightly\youtube_dl\extractor\youtube.py", line 3335, in _real_extract
File "D:\a\ytdl-nightly\ytdl-nightly\youtube_dl\extractor\youtube.py", line 312, in _extract_yt_initial_data
File "D:\a\ytdl-nightly\ytdl-nightly\youtube_dl\extractor\common.py", line 1045, in _search_regex
youtube_dl.utils.RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

@dirkf
Copy link
Contributor

dirkf commented Aug 11, 2023

YT is now ignoring the ucbc=1 parameter that the extractor adds and redirecting via consent.youtube.com, for some pages. There is a fix but meanwhile try passing cookies from a browser session where you have already gone through the consent check, using the nightly build.

See also yt-dlp/yt-dlp#7594.

@dirkf dirkf added the broken-IE problem with existing site extraction label Aug 21, 2023
@facundobatista
Copy link

Hello! Do you have instructions on how to pass the cookies from a browser session? Thanks!

@dirkf
Copy link
Contributor

dirkf commented Aug 24, 2023

See manual and FAQ.

@Konubinix
Copy link

I came accross the issue with consent yesterday.

For people using qutebrowser, you first need to convert its cookies into netscape format.

I used https://gist.github.com/guidocella/a272b6e68f9c44532b011f6596e95c61#file-dump-cookies-sh to do so and then youtube-dl --cookies $XDG_RUNTIME_DIR/cookies.txt

Just posting this in case it saves some people some trouble.

@mdavis-xyz
Copy link

Using a VPN to move from the EU to outside the EU is also a workaround.

@ghost
Copy link

ghost commented Aug 31, 2023

youtube-dl --cookies www.youtube.com_cookies.txt -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU --verbose
[debug] System config: [u'--no-mtime', u'-o', u'~/Downloads/YouTube/%(title)s.%(ext)s']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--cookies', u'www.youtube.com_cookies.txt', u'-f', u'bestvideo[height<=480]+bestaudio/best[height<=480]', u'PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU', u'--verbose']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2023.08.31.810 (single file build)
** This build is unofficial daily builds, provided for ease of use.
** Please do not ask for any support.
[debug] Python 2.7.18 (CPython x86_64 64bit) - Linux-5.15.0-79-generic-x86_64-with-LinuxMint-20.3-una - OpenSSL 1.1.1f  31 Mar 2020 - glibc 2.29
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7
[debug] Proxy map: {}
[youtube:tab] PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 825, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 846, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 535, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 3328, in _real_extract
    data = self._extract_yt_initial_data(item_id, webpage)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 312, in _extract_yt_initial_data
    self._YT_INITIAL_DATA_RE), webpage, 'yt initial data'),
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1013, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

So I updated to latest version with -U, then I passed cookies from my browser after consenting, making sure they are in netscape format. Still doesn't work... Would it help if I provided my cookies txt file?

@dirkf
Copy link
Contributor

dirkf commented Aug 31, 2023

You have to have consented in the browser and then export the cookies.

Although it may not make any difference, also review #30839 to update to a newer version: it will have an earlier date, but I think the ytdl-patched repo is not currently being updated even though builds are being run.

@ghost
Copy link

ghost commented Aug 31, 2023

Thank you for your answer, unfortunately it does not solve the issue, I have now updated to the nightly build but I still get the error message. I made sure to export cookies AFTER consenting to youtube cookies.

greg@greg-OptiPlex-3060:~$ youtube-dl --cookies www.youtube.com_cookies.txt -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU --verbose
[debug] System config: [u'--no-mtime', u'-o', u'~/Downloads/YouTube/%(title)s.%(ext)s']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--cookies', u'www.youtube.com_cookies.txt', u'-f', u'bestvideo[height<=480]+bestaudio/best[height<=480]', u'PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU', u'--verbose']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2023.08.07 [86e3cf5e5] (single file build)
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 2.7.18 (CPython x86_64 64bit) - Linux-5.15.0-79-generic-x86_64-with-LinuxMint-20.3-una - OpenSSL 1.1.1f  31 Mar 2020 - glibc 2.29
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7
[debug] Proxy map: {}
[youtube:tab] PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 863, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 959, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 565, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 3335, in _real_extract
    data = self._extract_yt_initial_data(item_id, webpage)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 312, in _extract_yt_initial_data
    self._YT_INITIAL_DATA_RE), webpage, 'yt initial data'),
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1045, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

@dirkf
Copy link
Contributor

dirkf commented Aug 31, 2023

That's quite surprising. Perhaps YT also requires you to set the UA header to match the browser that acquired the cookies. At any rate, I'm able to get the playlist with a (slightly fixed - hence why it is) WIP version:

$ python -m youtube_dl --flat-playlist 'PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU'
[youtube:tab] PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU: Downloading webpage
[download] Downloading playlist: Superwings S1
[youtube:tab] playlist Superwings S1: Downloading 23 videos
[download] Downloading video 1 of 23
[download] Downloading video 2 of 23
[download] Downloading video 3 of 23
[download] Downloading video 4 of 23
[download] Downloading video 5 of 23
[download] Downloading video 6 of 23
[download] Downloading video 7 of 23
[download] Downloading video 8 of 23
[download] Downloading video 9 of 23
[download] Downloading video 10 of 23
[download] Downloading video 11 of 23
[download] Downloading video 12 of 23
[download] Downloading video 13 of 23
[download] Downloading video 14 of 23
[download] Downloading video 15 of 23
[download] Downloading video 16 of 23
[download] Downloading video 17 of 23
[download] Downloading video 18 of 23
[download] Downloading video 19 of 23
[download] Downloading video 20 of 23
[download] Downloading video 21 of 23
[download] Downloading video 22 of 23
[download] Downloading video 23 of 23
[download] Finished downloading playlist: Superwings S1
$

@ghost
Copy link

ghost commented Sep 1, 2023

This is the output after passing my browser's User Agent header to youtube-dl. BTW - I'm using Brave browser. Unfortunately it still does not work. Note that the cookies file is named cookies2.txt it's because I also tried various methods like signing in to google, to no avail.

greg@greg-OptiPlex-3060:~$ youtube-dl --user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" --cookies www.youtube.com_cookies2.txt -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU --verbose
[debug] System config: [u'--no-mtime', u'-o', u'~/Downloads/YouTube/%(title)s.%(ext)s']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--user-agent', u'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36', u'--cookies', u'www.youtube.com_cookies2.txt', u'-f', u'bestvideo[height<=480]+bestaudio/best[height<=480]', u'PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU', u'--verbose']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2023.08.07 [86e3cf5e5] (single file build)
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 2.7.18 (CPython x86_64 64bit) - Linux-5.15.0-79-generic-x86_64-with-LinuxMint-20.3-una - OpenSSL 1.1.1f  31 Mar 2020 - glibc 2.29
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7
[debug] Proxy map: {}
[youtube:tab] PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 863, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 959, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 565, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 3335, in _real_extract
    data = self._extract_yt_initial_data(item_id, webpage)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 312, in _extract_yt_initial_data
    self._YT_INITIAL_DATA_RE), webpage, 'yt initial data'),
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1045, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

I also tried changing browser, thinking it might be an issue with Brave's agressive privacy behaviour. So here is the output of a fresh Firefox install, with cookies passed after consent and UA header:

greg@greg-OptiPlex-3060:~$ youtube-dl --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" --cookies FFcookies.txt -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' 'PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU' --verbose
[debug] System config: [u'--no-mtime', u'-o', u'~/Downloads/YouTube/%(title)s.%(ext)s']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--user-agent', u'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0', u'--cookies', u'FFcookies.txt', u'-f', u'bestvideo[height<=480]+bestaudio/best[height<=480]', u'PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU', u'--verbose']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2023.08.07 [86e3cf5e5] (single file build)
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 2.7.18 (CPython x86_64 64bit) - Linux-5.15.0-79-generic-x86_64-with-LinuxMint-20.3-una - OpenSSL 1.1.1f  31 Mar 2020 - glibc 2.29
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7
[debug] Proxy map: {}
[youtube:tab] PL-nQOC8BAGD2Y9TkorVGRBowfO1ILfFKU: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 863, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 959, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 565, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 3335, in _real_extract
    data = self._extract_yt_initial_data(item_id, webpage)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 312, in _extract_yt_initial_data
    self._YT_INITIAL_DATA_RE), webpage, 'yt initial data'),
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1045, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Interestingly enough it works with another video. I clicked one of the first things that appeared on my feed (https://www.youtube.com/watch?v=FxdbD-N7pHE) and was greeted with a successfull download with the same parameters. There were errors (unable to extract player URL), but the video was still downloaded succesfully. I posted it here since I think it might be more appropriate: ##32538 (comment)

@dirkf
Copy link
Contributor

dirkf commented Sep 1, 2023

Sadly, I'm out of ideas, except to expedite the QA on the extractor update.

@mdavis-xyz
Copy link

When I made that comment, I found that it didn't work for my French IP (without a VPN) and did for an Australian IP (PIA VPN to Sydney).

But now I'm trying again today in France and it kind of works. I see some tracebacks, but it still seems to download a file. So I think those tracebacks are somehow just for warnings. And I suspect they're unrelated.

$ youtube-dl "https://www.youtube.com/watch?v=IX6McAMbMIU"
[youtube] IX6McAMbMIU: Downloading webpage
[youtube] IX6McAMbMIU: Downloading API JSON
WARNING: unable to extract player URL; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
WARNING: [youtube] Unable to decode n-parameter: download likely to be throttled (expected string or bytes-like object, got 'NoneType' Traceback (most recent call last):
  File "/home/matthew/venv/lib/python3.11/site-packages/youtube_dl/extractor/youtube.py", line 1679, in _n_descramble
    self._player_cache[player_id] = self._extract_n_function(video_id, player_url)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matthew/venv/lib/python3.11/site-packages/youtube_dl/extractor/youtube.py", line 1644, in _extract_n_function
    player_id = self._extract_player_info(player_url)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matthew/venv/lib/python3.11/site-packages/youtube_dl/extractor/youtube.py", line 1476, in _extract_player_info
    id_m = re.search(player_re, player_url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/re/__init__.py", line 176, in search
    return _compile(pattern, flags).search(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
)
[youtube] IX6McAMbMIU: Downloading API JSON
[dashsegments] Total fragments: 3
[download] Destination: HANABI  - les règles du jeu !-IX6McAMbMIU.f137.mp4
[download]   0.4% of ~30.00MiB at 53.94KiB/s ETA 09:27^C

@dirkf
Copy link
Contributor

dirkf commented Sep 3, 2023

Based on #32533 (comment), the patch from yt-dlp solves the problem for EU users. PR here RSN

@ghost
Copy link

ghost commented Sep 5, 2023

this is the likely culprit:

Using a VPN to move from the EU to outside the EU is also a workaround.

if someone can name a specific country that triggers the error, I can check into this.

If it helps I live in Italy. It doesn't seem to be ISP related either. I tested it on my home network, a mobile hotspot and at work, so 3 different ISPs. I don't know why it should change anything, but I thought it was worth a try.
I don't have access to any VPN at the moment, so I couldn't test if moving to a country outside EU helps in this case.

BTW I can download single videos from the playlist I mentioned above, albeit at slower speed.

Based on #32533 (comment), the patch from yt-dlp solves the problem for EU users. PR here RSN

That's some moderately good news... Should we just move to yt-dlp until a fix is released?

@ghost
Copy link

ghost commented Sep 5, 2023

using Italy with current master, I do not get an outright failure, but it does fail to remove the throttling, which might be a separate issue:

> youtube-dl IX6McAMbMIU
[youtube] IX6McAMbMIU: Downloading webpage
[youtube] IX6McAMbMIU: Downloading API JSON
WARNING: unable to extract player URL; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
WARNING: [youtube] Unable to decode n-parameter: download likely to be throttled (expected string or bytes-like object Traceback (most recent call last):
  File "C:\python\lib\site-packages\youtube_dl\extractor\youtube.py", line 1679, in _n_descramble
    self._player_cache[player_id] = self._extract_n_function(video_id, player_url)
  File "C:\python\lib\site-packages\youtube_dl\extractor\youtube.py", line 1644, in _extract_n_function
    player_id = self._extract_player_info(player_url)
  File "C:\python\lib\site-packages\youtube_dl\extractor\youtube.py", line 1476, in _extract_player_info
    id_m = re.search(player_re, player_url)
  File "re.py", line 200, in search
TypeError: expected string or bytes-like object
)
[youtube] IX6McAMbMIU: Downloading API JSON
[dashsegments] Total fragments: 3
[download] Destination: HANABI  - les règles du jeu !-IX6McAMbMIU.f137.mp4
[download]   6.0% of ~30.00MiB at 79.29KiB/s ETA 06:04

@dirkf
Copy link
Contributor

dirkf commented Sep 5, 2023

If the initial player response JSON can't be extracted, the extractor tries to proceed by fetching equivalent JSON from /youtubei/v1/player?videoId={video_id}.

The media links can be extracted from the .streamingData member, but the extractor only knows how to pull the player JS URL from the full web page (containing the initial player response) and not from the JSON (if it's even sent), so the unscrambling logic can't be used.

@nicolaasjan
Copy link

@1268
> WARNING: [youtube] Unable to decode n-parameter: download likely to be throttled
I faced the same.
See issue #32534.

Until the patch arrives, you can apply this diff:

diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 9c419c0..3bf483c 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -260,16 +260,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
         cookies = self._get_cookies('https://www.youtube.com/')
         if cookies.get('__Secure-3PSID'):
             return
-        consent_id = None
-        consent = cookies.get('CONSENT')
-        if consent:
-            if 'YES' in consent.value:
-                return
-            consent_id = self._search_regex(
-                r'PENDING\+(\d+)', consent.value, 'consent', default=None)
-        if not consent_id:
-            consent_id = random.randint(100, 999)
-        self._set_cookie('.youtube.com', 'CONSENT', 'YES+cb.20210328-17-p0.en+FX+%s' % consent_id)
+        socs = cookies.get('SOCS')
+        if socs and not socs.value.startswith('CAA'):  # not consented
+            return
+        self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True)  # accept all (required for mixes)
 
     def _real_initialize(self):
         self._initialize_consent()

Then it works fine again:

youtube-dl -v --ignore-config IX6McAMbMIU
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--ignore-config', 'IX6McAMbMIU']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2023.09.01.1
[debug] Lazy loading extractors enabled
[debug] Single file build
[debug] Python 3.8.10 (CPython x86_64 64bit) - Linux-5.4.0-162-generic-x86_64-with-glibc2.29 - OpenSSL 1.1.1f  31 Mar 2020 - glibc 2.31
[debug] exe versions: ffmpeg N-111711-gd295b6b693-Nico-20230808, ffprobe N-111711-gd295b6b693-Nico-20230808, phantomjs 2.1.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] IX6McAMbMIU: Downloading webpage
[youtube] IX6McAMbMIU: Downloading player 0a835141
[debug] [youtube] Decrypted nsig eMLFU58o3Ty3bHwmpN => PP6OPqsJ8SF-SQ
[debug] [youtube] Decrypted nsig JGB6co7DtTFZlRKSTI => YxvEq0bReXPeUg
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://rr2---sn-5hnednsz.googlevideo.com/videoplayback?expire=1694039823&ei=r6r4ZKvYGP666dsP4peCWA&ip=<REDACTED>&id=o-AE2Owhk2eLmFpqf1G0FqTEgP1BwezlGU05dRLXbbL2o1&itag=137&aitags=134%2C136%2C137%2C160%2C243&source=youtube&requiressl=yes&mh=Um&mm=31%2C26&mn=sn-5hnednsz%2Csn-4g5e6ns7&ms=au%2Conr&mv=m&mvi=2&pl=14&initcwndbps=2287500&spc=UWF9f3LCXGIQrdCG4aCP0tADEGG8B6rbIbJyHBMF4A&vprv=1&svpuc=1&mime=video%2Fmp4&ns=jfIQASlWGQvPGTF0VTpiDbwP&gir=yes&clen=25280532&dur=401.767&lmt=1693365754427220&mt=1694017749&fvip=3&keepalive=yes&fexp=24007246%2C24362685&beids=24350018&c=WEB&txp=6219224&n=PP6OPqsJ8SF-SQ&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANPoyNjGdMsqc_doYoBWsy34L_nEI6wn9EbWwn909atVAiBFqVyq-6cllVcGYPN2R6EsVXyoiD0EeU1llgWIYYoq1Q%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgFz9MBbhqbJ_Ev0EWGo2rRJYdQEZ-1Ck4qdyYCWsq9GYCIBj8HKenFbJkrEyhmp4NSj10w-GqcLqrj17bD8Y7CXQQ'
[dashsegments] Total fragments: 3
[download] Destination: HANABI  - les règles du jeu !-IX6McAMbMIU.f137.mp4
[download] 100% of 24.11MiB in 00:02
[debug] Invoking downloader on 'https://rr2---sn-5hnednsz.googlevideo.com/videoplayback?expire=1694039823&ei=r6r4ZKvYGP666dsP4peCWA&ip=<REDACTED>&id=o-AE2Owhk2eLmFpqf1G0FqTEgP1BwezlGU05dRLXbbL2o1&itag=140&source=youtube&requiressl=yes&mh=Um&mm=31%2C26&mn=sn-5hnednsz%2Csn-4g5e6ns7&ms=au%2Conr&mv=m&mvi=2&pl=14&initcwndbps=2287500&spc=UWF9f3LCXGIQrdCG4aCP0tADEGG8B6rbIbJyHBMF4A&vprv=1&svpuc=1&mime=audio%2Fmp4&ns=jfIQASlWGQvPGTF0VTpiDbwP&gir=yes&clen=6504156&dur=401.844&lmt=1693365762273497&mt=1694017749&fvip=3&keepalive=yes&fexp=24007246%2C24362685&beids=24350018&c=WEB&txp=6218224&n=PP6OPqsJ8SF-SQ&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAI0HlshLS04cTLtsvCEmR84feV0gb-jUCImXXCz0VjOoAiA5AFpNKO-xA_2-YXUgP0kxsQiqVwxVsaZI8xRAvjvRRQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgFz9MBbhqbJ_Ev0EWGo2rRJYdQEZ-1Ck4qdyYCWsq9GYCIBj8HKenFbJkrEyhmp4NSj10w-GqcLqrj17bD8Y7CXQQ'
[dashsegments] Total fragments: 1
[download] Destination: HANABI  - les règles du jeu !-IX6McAMbMIU.f140.m4a
[download] 100% of 6.20MiB in 00:00
[ffmpeg] Merging formats into "HANABI  - les règles du jeu !-IX6McAMbMIU.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:HANABI  - les règles du jeu !-IX6McAMbMIU.f137.mp4' -i 'file:HANABI  - les règles du jeu !-IX6McAMbMIU.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'file:HANABI  - les règles du jeu !-IX6McAMbMIU.temp.mp4'
Deleting original file HANABI  - les règles du jeu !-IX6McAMbMIU.f137.mp4 (pass -k to keep)
Deleting original file HANABI  - les règles du jeu !-IX6McAMbMIU.f140.m4a (pass -k to keep)

@ghost
Copy link

ghost commented Sep 6, 2023

thanks but I don't actually use YouTube-DL, I use my own tool. I was just trying to help troubleshoot the potential geo block issue.

@daald
Copy link

daald commented Sep 23, 2023

sorry, I can't reproduce it myself today (2023.09.07 and 2021.12.17), so just forget about it.
as far I remember, I had played around with user-agent and cookies and it simply never worked until I moved all these arguments to the front. and I remember one day where I had a -x afterwards and it downloaded a video instead of music. i know, it's not how parameters are supposed to work, that's why I wrote it.

@ReenigneArcher
Copy link
Contributor

I have the same Problem with Playlists. I'm here in Germany. I found out, that It will restart Downloading for a few Videos when I update the Cookie file and then I get the Error again. Hope that will help.

This Patch has fixed the problem in my case. yt-dlp/yt-dlp@378ae9f

Is there a PR up for this?

Also, this affects individual videos, not only playlists. I think the title of this issue should be edited to unable to extract player URL

@dirkf
Copy link
Contributor

dirkf commented Nov 12, 2023

Is there a PR up for this?

Any minute now.

@a-pav
Copy link

a-pav commented Nov 18, 2023

RE Cookie extraction.
Please don't use any utility or install shady browser extensions just to extract the cookies, that's ridiculous!

Run

(() => {
    // Paste value of cookie's header obtained from network tab between the quotes,
    // or leave it as empty string.
    let COOKIE = '' || document.cookie;

    copy(
        '# Netscape HTTP Cookie File\n' +
        COOKIE.split(/; /g)
            .map(e => e.replace('=', '\t'))
            .map(e => window.location.hostname.replace('www.', '') + '\tFALSE\t/\tTRUE\t0\t' + e)
            .join('\n')
    )
})()

inside your browser console and the Netscape-formatted cookies will be copied to your clipboard. Paste inside a cookie.txt file and pass it to youtube-dl like --cookies ./cookie.txt.

Note: document.cookie seems to have all the necessary cookie values which are needed for a successful youtube-dl operation. But if that ever failed, try copying Cookie: header's value from your browser's network tab and paste it between the quotes indicated in the snippet, and try again. So far I haven't had to do that in my usage.

@dirkf Please promote this method anywhere you can. It's by far the safest and easiest way to get the cookies.

@dirkf
Copy link
Contributor

dirkf commented Nov 18, 2023

We previously identified an apparently reliable browser extension that generates the necessary cookie file, and that's what the online documentation recommends.

@a-pav
Copy link

a-pav commented Nov 19, 2023

I understand that for the online documentation you probably want to stick with recommending something that just works.

But since most people don't know how to extract their cookies, youtube-dl documentation currently makes it look like that an extra, special tool is needed to do that.

Perhaps if youtube-dl had a --cookies-raw FILE option to pass raw key=value; key=value; <...> cookie pairs, then obtaining cookies would be a matter of copying it from browser's network tab. No special tool needed.

Now I wonder if --add-header FIELD:VALUE option could be used to pass cookies like:
--add-header 'Cookie: key=value; <...>'?

@dirkf
Copy link
Contributor

dirkf commented Nov 19, 2023

It could, but see the pinned security issue #32450 for why --cookies ... is preferred. (tldr; cookies need to be associated with specific domains, and the cookie header does not contain that information: the cookie file is the pig while the header is a sausage).

@dirkf
Copy link
Contributor

dirkf commented Nov 22, 2023

I'll keep this open until there's a fixed release.

@janacm
Copy link

janacm commented Jan 9, 2024

RE Cookie extraction. Please don't use any utility or install shady browser extensions just to extract the cookies, that's ridiculous!

Run

(() => {
    // Paste value of cookie's header obtained from network tab between the quotes,
    // or leave it as empty string.
    let COOKIE = '' || document.cookie;

    copy(
        '# Netscape HTTP Cookie File\n' +
        COOKIE.split(/; /g)
            .map(e => e.replace('=', '\t'))
            .map(e => window.location.hostname.replace('www.', '') + '\tFALSE\t/\tTRUE\t0\t' + e)
            .join('\n')
    )
})()

inside your browser console and the Netscape-formatted cookies will be copied to your clipboard. Paste inside a cookie.txt file and pass it to youtube-dl like --cookies ./cookie.txt.

Note: document.cookie seems to have all the necessary cookie values which are needed for a successful youtube-dl operation. But if that ever failed, try copying Cookie: header's value from your browser's network tab and paste it between the quotes indicated in the snippet, and try again. So far I haven't had to do that in my usage.

@dirkf Please promote this method anywhere you can. It's by far the safest and easiest way to get the cookies.

Hey I get undefined when running this

@dirkf
Copy link
Contributor

dirkf commented Jan 9, 2024

Perhaps the poster has this function from SO. Anyhow, s/copy/return/, but generally #32499 (comment) applies.

@a-pav
Copy link

a-pav commented Jan 10, 2024

I get undefined when running this

undefined what exactly? You should mention this, since virtually everything is undefined inside a browser console except the things that are not.
I just ran the snippet in Firefox console with success. There should be no problem in a chrome console as well. Make sure to use the snippet in its entirety.
If copy function is undefined, try writing the resultant string somewhere in DOM (within an element) and copy it manually from there. clipboard.writeText might be another option, but seems unnecessary.

@PerryRylance

This comment was marked as spam.

@DawidKrysiak
Copy link

DawidKrysiak commented Feb 11, 2024

I came accross the issue with consent yesterday.

For people using qutebrowser, you first need to convert its cookies into netscape format.

I used https://gist.github.com/guidocella/a272b6e68f9c44532b011f6596e95c61#file-dump-cookies-sh to do so and then youtube-dl --cookies $XDG_RUNTIME_DIR/cookies.txt

Just posting this in case it saves some people some trouble.

For any new user googling for that. THAT is the correct interim solution. Let's be honest, google does what they can to block downloading.
So the solution is:
use a plugin (e.g. 'get cookies.txt clean') downdload your youtube cookies, then

youtube-dl --cookies all_cookies.txt http://youtube.com/<channel>

@dirkf
Copy link
Contributor

dirkf commented Feb 11, 2024

The consent issue is fixed in the nightly build which you should be using.

@8tm
Copy link

8tm commented Mar 10, 2024

RE Cookie extraction. Please don't use any utility or install shady browser extensions just to extract the cookies, that's ridiculous!

Run

(() => {
    // Paste value of cookie's header obtained from network tab between the quotes,
    // or leave it as empty string.
    let COOKIE = '' || document.cookie;

    copy(
        '# Netscape HTTP Cookie File\n' +
        COOKIE.split(/; /g)
            .map(e => e.replace('=', '\t'))
            .map(e => window.location.hostname.replace('www.', '') + '\tFALSE\t/\tTRUE\t0\t' + e)
            .join('\n')
    )
})()

inside your browser console and the Netscape-formatted cookies will be copied to your clipboard. Paste inside a cookie.txt file and pass it to youtube-dl like --cookies ./cookie.txt.

Note: document.cookie seems to have all the necessary cookie values which are needed for a successful youtube-dl operation. But if that ever failed, try copying Cookie: header's value from your browser's network tab and paste it between the quotes indicated in the snippet, and try again. So far I haven't had to do that in my usage.

@dirkf Please promote this method anywhere you can. It's by far the safest and easiest way to get the cookies.

Where this code should be added?

@ReenigneArcher
Copy link
Contributor

Where this code should be added?

In the console of your web browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broken-IE problem with existing site extraction fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.