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.39k stars 9.96k forks source link

[Youtube] Unable to extract nsig function code with 2024.07.25 #32888

Closed yanmiao2 closed 1 month ago

yanmiao2 commented 1 month ago

Checklist

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=ab8EQZSWQOk', '--verbose']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2024.07.25 [e1b3fa242]
[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-6.5.0-44-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
[debug] Proxy map: {}
[youtube] ab8EQZSWQOk: Downloading webpage
[youtube] ab8EQZSWQOk: 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.
Traceback (most recent call last):
  File "/home/cps/.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/cps/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1690, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/cps/.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/cps/.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/cps/.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/cps/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1690, in _extract_n_function_code
    func_name = self._extract_n_function_name(jscode)
  File "/home/cps/.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/cps/.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/cps/.local/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "/home/cps/.local/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 975, in __extract_info
    ie_result = ie.extract(url)
  File "/home/cps/.local/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "/home/cps/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 2108, in _real_extract
    self._unthrottle_format_urls(video_id, player_url, dct)
  File "/home/cps/.local/lib/python3.10/site-packages/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/cps/.local/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py", line 1614, in inner
    raise ret
  File "/home/cps/.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/cps/.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.

Description

Using the latest 2024.07.25 version and already checked https://github.com/ytdl-org/youtube-dl/issues/30839, still having issue with simple command like youtube-dl https://www.youtube.com/watch?v=ab8EQZSWQOk

SamDDBS commented 1 month ago

Will ditto that i have this same issue, also version 2024.07.25. Tried downloading a playlist and got the same errors for every video it tried bugreport.txt

Haifen commented 1 month ago

Confirming the same issue, commit e1b3fa2 (AKA 2024.07.25 I guess :shrug:). Output of youtube-dl --verbose -F https://youtu.be/tSMR2Lf40X4 is attached. youtube-dl--verbose-F_https___youtu.be_tSMR2Lf40X4-output-2024073101.txt Also confirming this is a likely duplicate of #32885 (@dirkf references yt-dlt/yt-dlp#10608, which in turn references yt-dlt/yt-dlp#10611, which may be possible to merge into youtube-dl (not tried to merge from yt-dlp's extractor into youtube-dl's).

ShantanuNair commented 1 month ago

The fix is in the 2024.08.01.000109 master release.

yanmiao2 commented 1 month ago

The fix is in the 2024.08.01.000109 master release.

I'm quite confused, the link you gave points a different repo yt-dlp, isn't that a different library this (youtube-dl)?

rasterfarm commented 1 month ago

diff.txt Attached is a patch that resolves the issue. Thanks to yt-dlp team.

Haifen commented 1 month ago

Did a quick & dirty cherry-pick of upstream, and was about to make a git-am patch of it, but @rasterfarm was quicker on the draw, and did a better merge of upstream's changes. Patch applies, merges (using Gentoo to test), and fixes the issue. Would make a pull, but don't want to take credit for @bashonly and @rasterfarm's work. Will do it if no-one else does, with full attribution.

robybeen commented 1 month ago

which release is the newest without this issue ? (and as such works out of the box)

dirkf commented 1 month ago

32885

dirkf commented 3 weeks ago

Please don't post in closed duplicate issues unless there is an enormously good reason. Otherwise I'll have to enforce that by locking such issues.

Apparently your git checkout isn't running the code that's in the listed commit: somehow an older version of one or more files is in use. Here's the nightly release built from the same commit succeeding with the same player JS:

$ youtube-dl -vF 'https://www.youtube.com/watch?v=ektquhrxjAM'
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-vF', 'https://www.youtube.com/watch?v=ektquhrxjAM']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2024.08.07 [c5098961b] (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.11.2 (CPython i686 32bit) - Linux-6.1.0-23-686-pae-i686-with-glibc2.36 - OpenSSL 3.0.13 30 Jan 2024 - glibc 2.36
[debug] exe versions: ffmpeg 5.1.6-0, ffprobe 5.1.6-0
[debug] Proxy map: {}
[youtube] ektquhrxjAM: Downloading webpage
[youtube] ektquhrxjAM: Downloading player a87a9450
[debug] [youtube] Decrypted nsig 23AN4QesVquvXjeR => _GOqNQUr7bNCRQ
[debug] [youtube] Decrypted nsig a7AWogGWVdxsgh6w => Kd0s5Y0vEynDcQ
[info] Available formats for ektquhrxjAM:
format code  extension  resolution note
249          webm       audio only audio_quality_low   46k , webm_dash container, opus  (48000Hz), 32.78MiB
249-drc      webm       audio only audio_quality_low   48k , webm_dash container, opus  (48000Hz), 33.60MiB
250          webm       audio only audio_quality_low   60k , webm_dash container, opus  (48000Hz), 41.93MiB
250-drc      webm       audio only audio_quality_low   60k , webm_dash container, opus  (48000Hz), 42.17MiB
251-drc      webm       audio only audio_quality_medium  114k , webm_dash container, opus  (48000Hz), 79.75MiB
251          webm       audio only audio_quality_medium  114k , webm_dash container, opus  (48000Hz), 80.29MiB
140          m4a        audio only audio_quality_medium  129k , m4a_dash container, mp4a.40.2 (44100Hz), 90.47MiB
140-drc      m4a        audio only audio_quality_medium  129k , m4a_dash container, mp4a.40.2 (44100Hz), 90.47MiB
160          mp4        194x144    144p   61k , mp4_dash container, avc1.4d400c, 30fps, video only, 43.23MiB
278          webm       194x144    144p   68k , webm_dash container, vp9, 30fps, video only, 48.01MiB
242          webm       324x240    240p  111k , webm_dash container, vp9, 30fps, video only, 77.83MiB
133          mp4        324x240    240p  129k , mp4_dash container, avc1.4d400d, 30fps, video only, 90.73MiB
243          webm       488x360    360p  175k , webm_dash container, vp9, 30fps, video only, 122.97MiB
134          mp4        488x360    360p  240k , mp4_dash container, avc1.4d401e, 30fps, video only, 168.28MiB
244          webm       650x480    480p  286k , webm_dash container, vp9, 30fps, video only, 200.29MiB
135          mp4        650x480    480p  441k , mp4_dash container, avc1.4d401e, 30fps, video only, 308.53MiB
18           mp4        486x360    360p  331k , avc1.42001E, 30fps, mp4a.40.2 (44100Hz), 231.64MiB (best)
$