ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.2k stars 9.93k forks source link

[YouTube] Unable to extract nsig jsi ... #32842

Closed GregoriusT closed 1 month ago

GregoriusT commented 2 months ago

Checklist

Verbose log


==========================
TESTING NORMAL YOUTUBE-DL:
==========================

[debug] System config: []
[debug] User config: ['--no-mtime', '--match-filter', '!is_live', '--retries', 'infinite', '--fragment-retries', '3', '--skip-unavailable-fragments', '--restrict-filenames', '-i', '-o', '/home/gregorius/home/pending/videos/%(title)s___%(id)s.webm', '-f', '(bestvideo[height<=360]+worstaudio/best[height<=360])[protocol!=http_dash_segments][container!^=dash]', '--console-title', '--hls-prefer-native', '--no-cache-dir', '--http-chunk-size', '100M', '--cookies', '/home/gregorius/home/scripts/video/youtube-dl-cookies']
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=zPHM0q0xgFg', '-vf', '18', '--no-playlist', '-o', '/home/gregorius/home/scripts/video/TEST_NORMAL_%(title)s___%(id)s.webm']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Single file build
[debug] Python 3.10.12 (CPython x86_64 64bit) - Linux-5.15.0-112-generic-x86_64-with-glibc2.35 - OpenSSL 3.0.2 15 Mar 2022 - glibc 2.35
[debug] exe versions: ffmpeg 4.4.2, ffprobe 4.4.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] zPHM0q0xgFg: Downloading webpage
[youtube] Downloading just video zPHM0q0xgFg because of --no-playlist
[youtube] zPHM0q0xgFg: Downloading player b22ef6e7
ERROR: Unable to extract nsig jsi, player_id, func_codefunction code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1680, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1680, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/YoutubeDL.py", line 875, in wrapper
    return func(self, *args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/YoutubeDL.py", line 971, in __extract_info
    ie_result = ie.extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 2108, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1725, in _unthrottle_format_urls
    n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1606, in inner
    self._player_cache[cache_id] = func(*args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1639, in _decrypt_nsig
    raise ExtractorError('Unable to extract nsig jsi, player_id, func_codefunction code', cause=e)
youtube_dl.utils.ExtractorError: Unable to extract nsig jsi, player_id, func_codefunction code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

===========================
TESTING NIGHTLY YOUTUBE-DL:
===========================

[debug] System config: []
[debug] User config: ['--no-mtime', '--match-filter', '!is_live', '--retries', 'infinite', '--fragment-retries', '3', '--skip-unavailable-fragments', '--restrict-filenames', '-i', '-o', '/home/gregorius/home/pending/videos/%(title)s___%(id)s.webm', '-f', '(bestvideo[height<=360]+worstaudio/best[height<=360])[protocol!=http_dash_segments][container!^=dash]', '--console-title', '--hls-prefer-native', '--no-cache-dir', '--http-chunk-size', '100M', '--cookies', '/home/gregorius/home/scripts/video/youtube-dl-cookies']
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=zPHM0q0xgFg', '-vf', '18', '--no-playlist', '-o', '/home/gregorius/home/scripts/video/TEST_NIGHTLY_%(title)s___%(id)s.webm']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2024.07.08 [a452f9437] (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.10.12 (CPython x86_64 64bit) - Linux-5.15.0-112-generic-x86_64-with-glibc2.35 - OpenSSL 3.0.2 15 Mar 2022 - glibc 2.35
[debug] exe versions: ffmpeg 4.4.2, ffprobe 4.4.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] zPHM0q0xgFg: Downloading webpage
[youtube] Downloading just video zPHM0q0xgFg because of --no-playlist
[youtube] zPHM0q0xgFg: Downloading player b22ef6e7
ERROR: Unable to extract nsig jsi, player_id, func_codefunction code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1680, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1680, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/YoutubeDL.py", line 975, in __extract_info
    ie_result = ie.extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 2108, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1725, in _unthrottle_format_urls
    n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1606, in inner
    self._player_cache[cache_id] = func(*args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1639, in _decrypt_nsig
    raise ExtractorError('Unable to extract nsig jsi, player_id, func_codefunction code', cause=e)
youtube_dl.utils.ExtractorError: Unable to extract nsig jsi, player_id, func_codefunction code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

Description

New Error Message on Youtube, yay, time to provide the Devs with the Logs!

Unable to extract nsig jsi, player_id, func_codefunction code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m;

dirkf commented 2 months ago

Thanks for the report. YT have now discovered that JS a.split("") can be expressed as String.prototype.split.call(a, ""), and that there is also an Array class.

This should be fairly easy to fix, though maybe there's some more nonsense that I haven't yet noticed .

dirkf commented 2 months ago

Indeed, now it's been fixed twice:

$ python -m youtube_dl -vF zPHM0q0xgFg
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-vF', u'zPHM0q0xgFg']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: 0b2907665
[debug] Python 2.7.15 (CPython i686 32bit) - Linux-6.1.0-22-686-pae-i686-with-debian-12.6 - OpenSSL 1.1.1a  20 Nov 2018 - glibc 2.1.3
[debug] exe versions: ffmpeg 5.1.5-0, ffprobe 5.1.5-0
[debug] Proxy map: {}
[youtube] zPHM0q0xgFg: Downloading webpage
[debug] [youtube] Decrypted nsig M2_bGJLKmHc2Zr7Bh => rV2Hqx1WU9cpuw
[debug] [youtube] Decrypted nsig 7EPTM2rsj4Z306LCZ => cYnQHsXJW70IRA
[info] Available formats for zPHM0q0xgFg:
format code  extension  resolution note
249          webm       audio only audio_quality_low   49k , webm_dash container, opus  (48000Hz), 2.10MiB
250          webm       audio only audio_quality_low   64k , webm_dash container, opus  (48000Hz), 2.75MiB
251          webm       audio only audio_quality_medium  127k , webm_dash container, opus  (48000Hz), 5.42MiB
140          m4a        audio only audio_quality_medium  129k , m4a_dash container, mp4a.40.2 (44100Hz), 5.51MiB
160          mp4        256x144    144p   13k , mp4_dash container, avc1.4d400c, 30fps, video only, 573.67KiB
394          mp4        256x144    144p   18k , mp4_dash container, av01.0.00M.08, 30fps, video only, 823.95KiB
278          webm       256x144    144p   22k , webm_dash container, vp9, 30fps, video only, 985.53KiB
133          mp4        426x240    240p   20k , mp4_dash container, avc1.4d4015, 30fps, video only, 886.64KiB
395          mp4        426x240    240p   27k , mp4_dash container, av01.0.00M.08, 30fps, video only, 1.19MiB
242          webm       426x240    240p   32k , webm_dash container, vp9, 30fps, video only, 1.40MiB
134          mp4        640x360    360p   30k , mp4_dash container, avc1.4d401e, 30fps, video only, 1.28MiB
396          mp4        640x360    360p   46k , mp4_dash container, av01.0.01M.08, 30fps, video only, 1.96MiB
243          webm       640x360    360p   57k , webm_dash container, vp9, 30fps, video only, 2.46MiB
135          mp4        854x480    480p   40k , mp4_dash container, avc1.4d401f, 30fps, video only, 1.74MiB
397          mp4        854x480    480p   59k , mp4_dash container, av01.0.04M.08, 30fps, video only, 2.55MiB
244          webm       854x480    480p   78k , webm_dash container, vp9, 30fps, video only, 3.33MiB
136          mp4        1280x720   720p   85k , mp4_dash container, avc1.4d401f, 30fps, video only, 3.63MiB
398          mp4        1280x720   720p60  117k , mp4_dash container, av01.0.08M.08, 60fps, video only, 5.01MiB
298          mp4        1280x720   720p60  121k , mp4_dash container, avc1.4d4020, 60fps, video only, 5.16MiB
247          webm       1280x720   720p  129k , webm_dash container, vp9, 30fps, video only, 5.49MiB
302          webm       1280x720   720p60  167k , webm_dash container, vp9, 60fps, video only, 7.15MiB
399          mp4        1920x1080  1080p60  184k , mp4_dash container, av01.0.09M.08, 60fps, video only, 7.84MiB
299          mp4        1920x1080  1080p60  192k , mp4_dash container, avc1.64002a, 60fps, video only, 8.20MiB
303          webm       1920x1080  1080p60  245k , webm_dash container, vp9, 60fps, video only, 10.46MiB
18           mp4        640x360    360p  160k , avc1.42001E, 30fps, mp4a.40.2 (44100Hz), 6.81MiB (best)
$ 

And https://github.com/yt-dlp/yt-dlp/issues/10397#issuecomment-2218169122 too. I'll combine that in the upcoming yt-dl PR.

tansy commented 2 months ago

I have identically looking error. I use version 2024.07.08.

ERROR: Unable to extract nsig jsi, player_id, func_codefunction code (caused by RegexNotFoundError(u'Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m;

Full, verbose dump here.


PS.

I've verified that I'm running youtube-dl version 2021.12.17

To devs: would you mind to add small note about nightly builds for youtube-dl, possibly in follow the instructions section of #30839. Otherwise you'll get issues pertaining version 2021.12.17 forever and ever.

I was thinking about writing separate issue about it, and use easy to remember number like 32844, that is coming soon but maybe better to put it in #30839. Or maybe both.

dirkf commented 2 months ago

Use of nightly builds is already covered in #30839 but may need to be emphasised now that the old build is completely useless for its nominal purpose.

Once the patch is QAed, it'll be in the next nightly build: there won't be another until it's fixed. No more reports of the issue are needed; it's understood and reproducible.

GregoriusT commented 2 months ago

I will always provide logs for both normal and nightly in the youtube-specific issues I post, both of which from a freshly pulled and compiled instance of youtube-dl and youtube-dl-nightly, and since i use nightly to download all the stuff that I watch, I am quite quick at noticing errors that happen in both at least the same day they happen. ^^

Can't wait for this to be fixed/released, luckily i got a backlog of videos XD

yohanespm77 commented 1 month ago

how is the solution of this error ? Please help me

creidhne-a16i commented 1 month ago

how is the solution of this error ? Please help me

Did you read the comments on this issue? Devs know of the problem, fixed it on their end, and a fresh build is coming. Just wait for an update.

gamer191 commented 1 month ago

I'll combine that in the upcoming yt-dl PR.

Since I suspect this might cause you problems, please note that applying the 2nd commit without the 3rd commit will cause yt-dlp (and presumably also YouTube-dl) to incorrectly cache the new player, meaning nsig extraction will fail until you run --rm-cache-dir

vanleefxp commented 1 month ago

I'm getting this error message as well. I hope this would be fixed soon.

gamer191 commented 1 month ago

@van-lee-fxp switch to yt-dlp ;)

dirkf commented 1 month ago

... I suspect this might cause you problems ...

A problem I have previously encountered and also while debugging the fix that generated the log above. I just nullify the result of loading the bad cached code.

Duster98 commented 1 month ago
patched functions ```python def _extract_n_function_name(self, jscode): # func_name, idx = self._search_regex( # r'\.get\("n"\)\)&&\(b=(?P[a-zA-Z_$][\w$]*)(?:\[(?P\d+)\])?\([\w$]+\)', # jscode, 'Initial JS player n function name', group=('nfunc', 'idx')) # if not idx: # return func_name func_name, idx = self._search_regex(r'\.get\(b\)\)&&\(c=(?P[a-zA-Z_$][\w$]*)(?:\[(?P\d+)\])?\([\w$]+\)', jscode, 'Initial JS player n function name', group=('nfunc', 'idx')) if not idx: return func_name return self._parse_json(self._search_regex( r'var {0}\s*=\s*(\[.+?\])\s*[,;]'.format(re.escape(func_name)), jscode, 'Initial JS player n function list ({0}.{1})'.format(func_name, idx)), func_name, transform_source=js_to_json)[int(idx)] ``` ```python def _extract_n_function_code(self, video_id, player_url): player_id = self._extract_player_info(player_url) func_code = self.cache.load('youtube-nsig', player_id) jscode = func_code or self._load_player(video_id, player_url) jsi = JSInterpreter(jscode) if func_code: return jsi, player_id, func_code func_name = self._extract_n_function_name(jscode) # For redundancy # func_code = self._search_regex( # r'''(?xs)%s\s*=\s*function\s*\((?P[\w$]+)\)\s* # # NB: The end of the regex is intentionally kept strict # {(?P.+?}\s*return\ [\w$]+.join\(""\))};''' % func_name, # jscode, 'nsig function', group=('var', 'code'), default=None) func_code = self._search_regex(r'''(?xs)%s\s*=\s*function\s*\((?P[\w$]+)\)\s*{(?P.+?}\s*return\ Array\.prototype\.join\.call\([\w$]+,\s*""\))};''' % func_name, jscode, 'nsig function', group=('var', 'code'), default=None) var_name = '' match_var = re.search(r'var (\w+)=String\.prototype\.split\.call', func_code[1]) if match_var: var_name = match_var.group(1) temp_func_code = func_code[1].replace('String.prototype.split.call(a,"")', func_code[0] + '.split(\'\')') temp_func_code = temp_func_code.replace('Array.prototype.join.call(' + var_name + ',"")', var_name + '.join(\'\')') func_code = (func_code[0], temp_func_code) if func_code: func_code = ([func_code[0]], func_code[1]) else: self.write_debug('Extracting nsig function with jsinterp') func_code = jsi.extract_function_code(func_name) self.cache.store('youtube-nsig', player_id, func_code) return jsi, player_id, func_code ```

Hi guys, I have fix this two function

  1. problem -> regex in _extract_n_function_name was wrong
  2. problem -> regex in _extract_n_function_code was wrong
  3. problem -> JS compliler does not support String.prototype.split.call and Array.prototype.join.call

i can't commit now but if somebody can, please do it, this two function is located in youtube.py

patch with two functions for better code optimization ```python def _extract_n_function_name(self, jscode): func_name, idx = self._search_regex( r'\.get\(b\)\)&&\(c=(?P[a-zA-Z_$][\w$]*)(?:\[(?P\d+)\])?\([\w$]+\)', jscode, 'Initial JS player n function name', group=('nfunc', 'idx')) if not idx: return func_name return self._parse_json(self._search_regex( r'var {0}\s*=\s*(\[.+?\])\s*[,;]'.format(re.escape(func_name)), jscode, 'Initial JS player n function list ({0}.{1})'.format(func_name, idx)), func_name, transform_source=js_to_json)[int(idx)] def _extract_var_name(func_code): match_var = re.search(r'var (\w+)=String\.prototype\.split\.call', func_code) if match_var: return match_var.group(1) return None def _replace_func_code(func_code, var_input, var_name): temp_func_code = func_code.replace('String.prototype.split.call(' + var_input + ',"")', func_code.split('=')[0] + '.split(\'\')') if var_name: temp_func_code = temp_func_code.replace(f'Array.prototype.join.call({var_name},"")', f'{var_name}.join(\'\')') return temp_func_code def _extract_n_function_code(self, video_id, player_url): player_id = self._extract_player_info(player_url) func_code = self.cache.load('youtube-nsig', player_id) jscode = func_code or self._load_player(video_id, player_url) jsi = JSInterpreter(jscode) if func_code: return jsi, player_id, func_code func_name = self._extract_n_function_name(jscode) func_code = self._search_regex( r'''(?xs)%s\s=\sfunction\s\((?P[\w$]+)\)\s{(?P.+?}\sreturn\ Array\.prototype\.join\.call\([\w$]+,\s""\))};''' % func_name, jscode, 'nsig function', group=('var', 'code'), default=None) if func_code: var_name = _extract_var_name(func_code[1]) temp_func_code = _replace_func_code(func_code[1], func_code[0], var_name) func_code = (func_code[0], temp_func_code) else: self.write_debug('Extracting nsig function with jsinterp') func_code = jsi.extract_function_code(func_name) self.cache.store('youtube-nsig', player_id, func_code) return jsi, player_id, func_code ```
dirkf commented 1 month ago

@Duster98 thanks, but as you can see from https://github.com/ytdl-org/youtube-dl/issues/32842#issuecomment-2218272070 a fix is already in progress. Your approach looks like it solves the immediate problem and changes only one file but doesn't allow for future prototype-ey stuff. Impatient users could try your patch.

tansy commented 1 month ago

i can't commit now but if somebody can, please do it

Tried to test it but I'm unsure about lay two lines and their indentation. Would you mind to to attach or put in paste a diff/patch (`diff -rup youtube.py~ youtube.py > youtube.py.diff`)? Also I get these errors.

Ed. Managed to run the 'first', 'unoptimized' version and it works. Diff here. If that's your will, and devs agree can request a pull.

Duster98 commented 1 month ago

@tansy this is the file: youtube.py youtube.zip

If you can kindly test it so I can understand if at least temporarily the problem is solved

Duster98 commented 1 month ago

@dirkf Yes, I know, unfortunately it won't solve future problems. It might temporarily mitigate the issue. I'm working on a new solution and will let you know.

dirkf commented 1 month ago

A fix is already available but there are plenty of other issues that still need to be solved. The PR will be posted today; all being well, the subsequent nightly will include the merged PR.

tansy commented 1 month ago

A fix is already available

I just posted fix prepared by @Duster98. If that's good you can use it, if not then close it.

--

@Duster98: in case your PR was to be accepted please state a licence there.

yohanespm77 commented 1 month ago
image

I still got error on Pafy. Please help me

GregoriusT commented 1 month ago

Just came back to say, it works for me with both normal and nightly now, and consider this resolved for me, but I do compile it myself manually, so I can't tell for the things other people use. ^^

dirkf commented 1 month ago

I still got error on Pafy. Please help me

30839 "If your problem occurred when running another package that invokes youtube-dl, ..."

Plainly this isn't the Pafy issue tracker but the picture (text is always better) shows that the latest version is not being run. Take that with you.

dirkf commented 1 month ago

To reiterate the solution, the problem is fixed in the master code and builds of 2024--7-11 or later. You can install a fixed release from the nightly builds at ytdl-org/ytdl-nightly. If you are already running a nightly release, and depending on how you installed it, you may be able to update using -U.

If not:

  • a bundled executable for Windows XP or later is available
  • a bundled executable for any POSIX-ish OS (Linux, macOS, *BSD, ...) with a program invoked as python is available; if your Python is called python3, create a symbolic link or install a compatibility package (in some Linux Debian releases, _python_ispython3), or patch the name of the Python program in the executable using a binary editor or patcher (but must be repeated on each update); in any case remember to mark the download executable (chmod a+x ...)
  • you can also install using pip (actually, use python -m pip ... where python is how you invoke the Python that should run youtube-dl); something like python -m pip install "URL", where URL is that of the tar.gz archive on the release page, should work on recent pip versions; possibly also specify --force-reinstall.

Or if you are using Homebrew, you can install from the latest master code at that time using something like brew install --HEAD youtube-dl.

tansy commented 1 month ago

https://github.com/ytdl-org/youtube-dl/issues/32842#issuecomment-2218604078

Use of nightly builds is already covered in #30839 but may need to be emphasised now that the old build is completely useless for its nominal purpose.

Not enough. Told you. Noone is reaching this far (reading), or they don't get that.

It should be in first paragraph. Not '_If you want a version of youtubedl that can actually download from YouTube, use a recent nightly build' somewhere at the end, but rather something like 'Before you raise an issue make sure you use new version of youtube-dl, either built from master branch or compiled nightly build.'.

dirkf commented 1 month ago

Patience, please. I did say it needed to emphasised.

maxim-belkin commented 1 month ago

Or if you are using Homebrew, you can install from the latest master code at that time using something like brew install --HEAD youtube-dl.

Any chance you could tag a new release in this repo? Homebrew plans to disable youtube-dl package on 2024-11-23 due to it not having new releases since 2021, see brew info youtube-dl

dirkf commented 1 month ago
isArman commented 1 month ago

I was occurred the mentioned error during installation by dnf package manager. But it's resolved by installing with make file.

openbook commented 1 month ago

After upgrading to the latest nightly build, this issue was initially resolved but has since returned. I've followed the instructions in the rest of this thread:

  • ensuring I'm using the nightly build (which is youtube-dl version 2024.07.11 [16f5bbc46])
  • used the executable in the latest nightly release via a python command.

both of these options return the same error. Note I am using a cookies.txt file, I've tried recreating that with a new session, but that also hasn't resolved the issue. I've also tried this on a few youtube videos, all public, all return the same issue.

I've included the verbose debug output below, let me know if there is any other info I can provide.

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['9DzP5quXD_Y', '--cookies', './bin/cookies.txt', '--verbose']
WARNING: Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.
[debug] Encodings: locale ANSI_X3.4-1968, fs ascii, out ANSI_X3.4-1968, pref ANSI_X3.4-1968
[debug] youtube-dl version 2024.07.11 [16f5bbc46]
[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.6.9 (CPython x86_64 64bit) - Linux-4.4.0-145-generic-x86_64-with-Ubuntu-18.04-bionic - OpenSSL 1.1.1b  26 Feb 2019 - glibc 2.25
[debug] exe versions: ffmpeg 3.4.11, ffprobe 3.4.11
[debug] Proxy map: {}
[youtube] 9DzP5quXD_Y: Downloading webpage
[debug] [youtube] Extracting signature function js_3400486c_107
[youtube] 9DzP5quXD_Y: Downloading player 3400486c
ERROR: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.',)); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1668, in _extract_n_function_name
    ''', jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
  File "/application/yt/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1668, in _extract_n_function_name
    ''', jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
  File "/application/yt/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/application/yt/youtube-dl/youtube_dl/YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "/application/yt/youtube-dl/youtube_dl/YoutubeDL.py", line 975, in __extract_info
    ie_result = ie.extract(url)
  File "/application/yt/youtube-dl/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 2104, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1721, in _unthrottle_format_urls
    n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1606, in inner
    self._player_cache[cache_id] = func(*args, **kwargs)
  File "/application/yt/youtube-dl/youtube_dl/extractor/youtube.py", line 1639, in _decrypt_nsig
    raise ExtractorError('Unable to extract nsig function code', cause=e)
youtube_dl.utils.ExtractorError: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.',)); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
dirkf commented 1 month ago

Thanks for the report. I can't initially repro here but I am getting player 5604538d vs your 3400486c. Further investigation needed.

dirkf commented 1 month ago

A new circumlocution for "n" is used in the problem player:

...a.D&&(b="nn"[+a.D],c=a.get(b))&&(c=rDa[0](c),a.set(b,c),...

This patch addresses the problem:

     def _extract_n_function_name(self, jscode):
         func_name, idx = self._search_regex(
             # new: (b=String.fromCharCode(110),c=a.get(b))&&c=nfunc[idx](c)
+            # or:  (b="nn"[+a.D],c=a.get(b))&&(c=nfunc[idx](c),
             # old: .get("n"))&&(b=nfunc[idx](b)
             # older: .get("n"))&&(b=nfunc(b)
             r'''(?x)
-                (?:\(\s*(?P<b>[a-z])\s*=\s*String\s*\.\s*fromCharCode\s*\(\s*110\s*\)\s*,(?P<c>[a-z])\s*=\s*[a-z]\s*)?
-                \.\s*get\s*\(\s*(?(b)(?P=b)|"n")(?:\s*\)){2}\s*&&\s*\(\s*(?(c)(?P=c)|b)\s*=\s*
+                (?:\(\s*(?P<b>[a-z])\s*=\s*(?:
+                    String\s*\.\s*fromCharCode\s*\(\s*110\s*\)|
+                    "n+"\[\s*\+?s*[\w$.]+\s*]
+                )\s*,(?P<c>[a-z])\s*=\s*[a-z]\s*)?
+                \.\s*get\s*\(\s*(?(b)(?P=b)|"n{1,2}")(?:\s*\)){2}\s*&&\s*\(\s*(?(c)(?P=c)|b)\s*=\s*
                 (?P<nfunc>[a-zA-Z_$][\w$]*)(?:\s*\[(?P<idx>\d+)\])?\s*\(\s*[\w$]+\s*\)
             ''', jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
         if not idx:
dirkf commented 1 month ago
GregoriusT commented 1 month ago

I am only here because I am providing Logs, I saw the backlog and just wanted to make sure Data is being delivered. ^^

Edit: by the way it is still broken for player 1f8742dc

==========================
TESTING NORMAL YOUTUBE-DL:
==========================

[debug] System config: []
[debug] User config: ['--no-mtime', '--match-filter', '!is_live', '--retries', 'infinite', '--fragment-retries', '3', '--skip-unavailable-fragments', '--restrict-filenames', '-i', '-o', '/home/gregorius/home/pending/videos/%(title)s___%(id)s.webm', '-f', '(bestvideo[height<=360]+worstaudio/best[height<=360])[protocol!=http_dash_segments][container!^=dash]', '--console-title', '--hls-prefer-native', '--no-cache-dir', '--http-chunk-size', '100M', '--cookies', '/home/gregorius/home/scripts/video/youtube-dl-cookies']
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=zPHM0q0xgFg', '-vf', '18', '--no-playlist', '-o', '/home/gregorius/home/scripts/video/TEST_NORMAL_%(title)s___%(id)s.webm']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Single file build
[debug] Python 3.10.12 (CPython x86_64 64bit) - Linux-5.15.0-112-generic-x86_64-with-glibc2.35 - OpenSSL 3.0.2 15 Mar 2022 - glibc 2.35
[debug] exe versions: ffmpeg 4.4.2, ffprobe 4.4.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] zPHM0q0xgFg: Downloading webpage
[youtube] Downloading just video zPHM0q0xgFg because of --no-playlist
[youtube] zPHM0q0xgFg: Downloading player 1f8742dc
ERROR: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/YoutubeDL.py", line 875, in wrapper
    return func(self, *args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/YoutubeDL.py", line 971, in __extract_info
    ie_result = ie.extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 2104, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1721, in _unthrottle_format_urls
    n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1606, in inner
    self._player_cache[cache_id] = func(*args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-normal/youtube-dl/youtube_dl/extractor/youtube.py", line 1639, in _decrypt_nsig
    raise ExtractorError('Unable to extract nsig function code', cause=e)
youtube_dl.utils.ExtractorError: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

===========================
TESTING NIGHTLY YOUTUBE-DL:
===========================

[debug] System config: []
[debug] User config: ['--no-mtime', '--match-filter', '!is_live', '--retries', 'infinite', '--fragment-retries', '3', '--skip-unavailable-fragments', '--restrict-filenames', '-i', '-o', '/home/gregorius/home/pending/videos/%(title)s___%(id)s.webm', '-f', '(bestvideo[height<=360]+worstaudio/best[height<=360])[protocol!=http_dash_segments][container!^=dash]', '--console-title', '--hls-prefer-native', '--no-cache-dir', '--http-chunk-size', '100M', '--cookies', '/home/gregorius/home/scripts/video/youtube-dl-cookies']
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=zPHM0q0xgFg', '-vf', '18', '--no-playlist', '-o', '/home/gregorius/home/scripts/video/TEST_NIGHTLY_%(title)s___%(id)s.webm']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2024.07.11 [16f5bbc46] (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.10.12 (CPython x86_64 64bit) - Linux-5.15.0-112-generic-x86_64-with-glibc2.35 - OpenSSL 3.0.2 15 Mar 2022 - glibc 2.35
[debug] exe versions: ffmpeg 4.4.2, ffprobe 4.4.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] zPHM0q0xgFg: Downloading webpage
[youtube] Downloading just video zPHM0q0xgFg because of --no-playlist
[youtube] zPHM0q0xgFg: Downloading player 1f8742dc
ERROR: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/YoutubeDL.py", line 975, in __extract_info
    ie_result = ie.extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 2104, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1721, in _unthrottle_format_urls
    n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1606, in inner
    self._player_cache[cache_id] = func(*args, **kwargs)
  File "/home/gregorius/home/scripts/video/youtube-dl-nightly/youtube-dl/youtube_dl/extractor/youtube.py", line 1639, in _decrypt_nsig
    raise ExtractorError('Unable to extract nsig function code', cause=e)
youtube_dl.utils.ExtractorError: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
viebrix commented 1 month ago

It has already worked with the nightly build - but now it seems broken again:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=n7-Aj6vI2AA', '--verbose']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2024.07.11 [16f5bbc46]
[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.10.12 (CPython x86_64 64bit) - Linux-5.15.0-113-generic-x86_64-with-glibc2.35 - OpenSSL 3.0.2 15 Mar 2022 - glibc 2.35
[debug] exe versions: ffmpeg 4.4.2, ffprobe 4.4.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] n7-Aj6vI2AA: Downloading webpage
[youtube] n7-Aj6vI2AA: Downloading player 3400486c
ERROR: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1637, in _decrypt_nsig
    jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1686, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1660, in _extract_n_function_name
    func_name, idx = self._search_regex(
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player n function name; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 975, in __extract_info
    ie_result = ie.extract(url)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 2104, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1721, in _unthrottle_format_urls
    n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1606, in inner
    self._player_cache[cache_id] = func(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1639, in _decrypt_nsig
    raise ExtractorError('Unable to extract nsig function code', cause=e)
youtube_dl.utils.ExtractorError: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

Thank you for constantly working on these problems!

dirkf commented 1 month ago

Player 1f8742dc uses the same circumlocution as 3400486c.

derekatkins commented 1 month ago

I'm using https://github.com/ytdl-org/youtube-dl/commit/e1b3fa242cb94eb9dc949ab3f2cace91c46f11bf and still seeing this issue:

[youtube] Z8Fo2xZjpiE: Downloading player 20dfca59
ERROR: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.')); please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

Perhaps yet another player needs this?

megatron-uk commented 1 month ago

As per @derekatkins, I'm seeing the same error for player 20dfca59:

$ youtube-dl https://www.youtube.com/watch?v=LhXlKz5IrYY
[youtube] LhXlKz5IrYY: Downloading webpage
[youtube] LhXlKz5IrYY: Downloading player 20dfca59
ERROR: Unable to extract nsig function code (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player n function name\x1b[0m; please report this issue on https://github.com/ytdl-org/youtube-dl/issues

This is a source build against latest master branch, with following commit:

commit e1b3fa242cb94eb9dc949ab3f2cace91c46f11bf (HEAD -> master, origin/master, origin/HEAD)
Author: dirkf <fieldhouse@gmx.net>
Date:   Wed Jul 24 14:45:52 2024 +0100
dirkf commented 1 month ago

Do feel free to search for 20dfca59, say, following #30839 as asked, to find the actual issue #32885.