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

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

Closed
5 tasks done
GregoriusT opened this issue Jul 9, 2024 · 37 comments · Fixed by #32845
Closed
5 tasks done

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

GregoriusT opened this issue Jul 9, 2024 · 37 comments · Fixed by #32845
Labels
broken-IE problem with existing site extraction fixed yt-dlp working or fix available in yt-dlp

Comments

@GregoriusT
Copy link

Checklist

  • I'm reporting a broken site support
  • 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 issues including closed ones

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
Copy link
Contributor

dirkf commented Jul 9, 2024

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 dirkf changed the title [YOUTUBE] 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; [YouTube] Unable to extract nsig jsi ... Jul 9, 2024
@dirkf
Copy link
Contributor

dirkf commented Jul 9, 2024

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 yt-dlp/yt-dlp#10397 (comment) too. I'll combine that in the upcoming yt-dl PR.

@tansy
Copy link

tansy commented Jul 9, 2024

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

This comment was marked as outdated.

@GregoriusT
Copy link
Author

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

@dirkf dirkf added broken-IE problem with existing site extraction yt-dlp working or fix available in yt-dlp labels Jul 9, 2024
@yohanespm77

This comment was marked as resolved.

@creidhne-a16i

This comment was marked as resolved.

@gamer191
Copy link

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

This comment was marked as duplicate.

@gamer191

This comment was marked as off-topic.

@dirkf
Copy link
Contributor

dirkf commented Jul 10, 2024

... 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
Copy link

Duster98 commented Jul 10, 2024

patched functions
def _extract_n_function_name(self, jscode):
        # func_name, idx = self._search_regex(
        #     r'\.get\("n"\)\)&&\(b=(?P<nfunc>[a-zA-Z_$][\w$]*)(?:\[(?P<idx>\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<nfunc>[a-zA-Z_$][\w$]*)(?:\[(?P<idx>\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_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<var>[\w$]+)\)\s*
        #              # NB: The end of the regex is intentionally kept strict
        #              {(?P<code>.+?}\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<var>[\w$]+)\)\s*{(?P<code>.+?}\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
def _extract_n_function_name(self, jscode):
        func_name, idx = self._search_regex(
            r'\.get\(b\)\)&&\(c=(?P<nfunc>[a-zA-Z_$][\w$]*)(?:\[(?P<idx>\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<var>[\w$]+)\)\s{(?P<code>.+?}\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
Copy link
Contributor

dirkf commented Jul 10, 2024

@Duster98 thanks, but as you can see from #32842 (comment) 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
Copy link

tansy commented Jul 10, 2024

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
Copy link

Duster98 commented Jul 10, 2024

@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

This comment was marked as outdated.

tansy added a commit to tansy/youtube-dl that referenced this issue Jul 10, 2024
@dirkf

This comment was marked as outdated.

@tansy

This comment was marked as outdated.

@yohanespm77

This comment was marked as resolved.

@GregoriusT
Copy link
Author

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

This comment was marked as resolved.

@dirkf
Copy link
Contributor

dirkf commented Jul 12, 2024

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_is_python3), 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

This comment was marked as resolved.

@dirkf

This comment was marked as resolved.

@maxim-belkin
Copy link

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
Copy link
Contributor

dirkf commented Jul 20, 2024

There have been releases since last year.

#31585 (comment)

@seproDev seproDev mentioned this issue Jul 20, 2024
3 tasks
@isArman
Copy link

isArman commented Jul 21, 2024

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

@openbook
Copy link

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 [16f5bbc])
  • 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
Copy link
Contributor

dirkf commented Jul 24, 2024

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

@dirkf
Copy link
Contributor

dirkf commented Jul 24, 2024

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
Copy link
Contributor

dirkf commented Jul 24, 2024

Also fixed in yt-dlp/yt-dlp#10542.

@GregoriusT
Copy link
Author

GregoriusT commented Jul 24, 2024

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

This comment was marked as duplicate.

@dirkf
Copy link
Contributor

dirkf commented Jul 24, 2024

Player 1f8742dc uses the same circumlocution as 3400486c.

@derekatkins
Copy link

I'm using e1b3fa2 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
Copy link

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
Copy link
Contributor

dirkf commented Aug 1, 2024

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

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 yt-dlp working or fix available in yt-dlp
Projects
None yet
Development

Successfully merging a pull request may close this issue.