yt-dlp: [youtube] Native nsig extraction failed (Part 3)

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I remove or skip any mandatory* field

Checklist

  • I’m reporting a broken site
  • I’ve verified that I’m running yt-dlp version 2023.01.06 (update instructions) or later (specify commit)
  • I’ve checked that all provided URLs are playable in a browser with the same IP and same login details
  • 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. DO NOT post duplicates
  • I’ve read the guidelines for opening an issue
  • I’ve read about sharing account credentials and I’m willing to share it if required

Region

Southern Europe

Provide a description that is worded well enough to be understood

Since original #4635 has been a) closed, b) locked, I’m posting this (as a duplicate, I know - apologies 😉 ) to alert the team about the new breakage 😠 …

In the last hours of Jan 31st 2023 in my timezone, Google have shipped yt player dac945fd, which isn’t palatable to the native JS signature decryptor 😭 ; the code falls back to PhantomJS and the n-sig decryption then succeeds…

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

yt-dlp -vUF "p7FCgw_GlWc" --ie youtube => 

[debug] Command-line config: ['--ffmpeg-location', '..\\FFmpeg', '--downloader-args', 'ffmpeg:-v 8 -stats', '-vUF', 'p7FCgw_GlWc', '--ie', 'youtube']
[debug] Encodings: locale cp1253, fs utf-8, pref cp1253, out utf-8 (No VT), error utf-8 (No VT), screen utf-8 (No VT)
[debug] yt-dlp version 2023.01.31 [83c4970e5] (win_x86_exe)
[debug] Python 3.7.16 (CPython x86 32bit) - Windows-Vista-6.0.6003-SP2 (OpenSSL 1.1.1s  1 Nov 2022)
[debug] exe versions: ffmpeg n5.2-dev-2245-N-109649-gab8cde6 (setts), ffprobe n5.2-dev-2245-N-109649-gab8cde6, phantomjs 2.1.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Extractor Plugins: AGB+NSIG (YoutubeIE)
[debug] Plugin directories: ['<redacted>\\yt-dlp\\yt-dlp-plugins\\YTAgeGateBypass.zip\\yt_dlp_plugins', '<redacted>\\yt-dlp\\yt-dlp-plugins\\YTNSigProxy.zip\\yt_dlp_plugins']
[debug] Loaded 1 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2023.01.06, Current version: 2023.01.31
yt-dlp is up to date (2023.01.31)
[youtube+AGB+NSIG] Extracting URL: p7FCgw_GlWc
[youtube+AGB+NSIG] p7FCgw_GlWc: Downloading webpage
[youtube+AGB+NSIG] p7FCgw_GlWc: Downloading android player API JSON
[youtube+AGB+NSIG] p7FCgw_GlWc: Downloading tv embedded player API JSON
[youtube+AGB+NSIG] p7FCgw_GlWc: Downloading web embedded client config
[youtube+AGB+NSIG] p7FCgw_GlWc: Downloading player dac945fd
[youtube+AGB+NSIG] p7FCgw_GlWc: Downloading web embedded player API JSON
[debug] [youtube+AGB+NSIG] Extracting signature function js_dac945fd_110
[debug] Saving youtube-sigfuncs.js_dac945fd_110 to cache
[debug] Saving youtube-nsig.dac945fd to cache
WARNING: [youtube+AGB+NSIG] p7FCgw_GlWc: Native nsig extraction failed: Trying with PhantomJS
         n = CM1X2GXxvV6DnIngBB_3JZ ; player = https://www.youtube.com/s/player/dac945fd/player_ias.vflset/en_US/base.js
[debug] [youtube+AGB+NSIG] Signature function returned an exception; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
[youtube+AGB+NSIG] p7FCgw_GlWc: Executing signature code
[debug] [youtube+AGB+NSIG] PhantomJS command line: phantomjs "--ssl-protocol=any" "C:\Users\<redacted>\AppData\Local\Temp\tmp5jwo0rhl"
[debug] [youtube+AGB+NSIG] Decrypted nsig CM1X2GXxvV6DnIngBB_3JZ => 7_ThGFhQ0nuuyQ
[debug] Loading youtube-nsig.dac945fd from cache
WARNING: [youtube+AGB+NSIG] p7FCgw_GlWc: Native nsig extraction failed: Trying with PhantomJS
         n = 4sl9vdkJyZenf4-GQROY3b ; player = https://www.youtube.com/s/player/dac945fd/player_ias.vflset/en_US/base.js
[youtube+AGB+NSIG] p7FCgw_GlWc: Executing signature code
[debug] [youtube+AGB+NSIG] PhantomJS command line: phantomjs "--ssl-protocol=any" "C:\Users\<redacted>\AppData\Local\Temp\tmpptgw_phd"
[debug] [youtube+AGB+NSIG] Decrypted nsig 4sl9vdkJyZenf4-GQROY3b => PxVLDoRYUISU7A
[debug] [youtube+AGB+NSIG] Extracting signature function js_dac945fd_106
[debug] Saving youtube-sigfuncs.js_dac945fd_106 to cache
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[info] Available formats for p7FCgw_GlWc:
ID      EXT   RESOLUTION FPS CH |   FILESIZE   TBR PROTO | VCODEC          VBR ACODEC      ABR ASR MORE INFO
-------------------------------------------------------------------------------------------------------------------------
sb2     mhtml 48x27        0    |                  mhtml | images                   storyboard
sb1     mhtml 80x45        0    |                  mhtml | images                   storyboard
sb0     mhtml 160x90       0    |                  mhtml | images                   storyboard
249-drc webm  audio only      2 |    3.89MiB   51k https | audio only          opus        51k 48k low, DRC, webm_dash
250-drc webm  audio only      2 |    5.04MiB   66k https | audio only          opus        66k 48k low, DRC, webm_dash
249     webm  audio only      2 |    3.89MiB   51k https | audio only          opus        51k 48k low, webm_dash
250     webm  audio only      2 |    5.05MiB   67k https | audio only          opus        67k 48k low, webm_dash
140-drc m4a   audio only      2 |    9.83MiB  129k https | audio only          mp4a.40.2  129k 44k medium, DRC, m4a_dash
251-drc webm  audio only      2 |    9.65MiB  127k https | audio only          opus       127k 48k medium, DRC, webm_dash
140     m4a   audio only      2 |    9.83MiB  129k https | audio only          mp4a.40.2  129k 44k medium, m4a_dash
251     webm  audio only      2 |    9.70MiB  128k https | audio only          opus       128k 48k medium, webm_dash
394     mp4   256x144     30    |    6.40MiB   84k https | av01.0.00M.08   84k video only          144p, mp4_dash
160     mp4   256x144     30    |    2.53MiB   33k https | avc1.4d400c     33k video only          144p, mp4_dash
278     webm  256x144     30    |    6.12MiB   81k https | vp9             81k video only          144p, webm_dash
395     mp4   426x240     30    |   14.41MiB  190k https | av01.0.00M.08  190k video only          240p, mp4_dash
133     mp4   426x240     30    |    4.23MiB   56k https | avc1.4d4015     56k video only          240p, mp4_dash
242     webm  426x240     30    |    5.17MiB   68k https | vp9             68k video only          240p, webm_dash
396     mp4   640x360     30    |   22.87MiB  301k https | av01.0.01M.08  301k video only          360p, mp4_dash
134     mp4   640x360     30    |    8.67MiB  114k https | avc1.4d401e    114k video only          360p, mp4_dash
18      mp4   640x360     30  2 | ~ 12.63MiB  162k https | avc1.42001E    162k mp4a.40.2    0k 22k 360p
243     webm  640x360     30    |    9.90MiB  130k https | vp9            130k video only          360p, webm_dash
397     mp4   854x480     30    |   41.59MiB  548k https | av01.0.04M.08  548k video only          480p, mp4_dash
135     mp4   854x480     30    |   14.71MiB  194k https | avc1.4d401f    194k video only          480p, mp4_dash
244     webm  854x480     30    |   15.81MiB  208k https | vp9            208k video only          480p, webm_dash
22      mp4   1280x720    30  2 | ~ 45.22MiB  582k https | avc1.64001F    582k mp4a.40.2    0k 44k 720p
398     mp4   1280x720    30    |   84.46MiB 1112k https | av01.0.05M.08 1112k video only          720p, mp4_dash
136     mp4   1280x720    30    |   34.36MiB  453k https | avc1.4d401f    453k video only          720p, mp4_dash
247     webm  1280x720    30    |   30.57MiB  403k https | vp9            403k video only          720p, webm_dash
399     mp4   1920x1080   30    |  133.61MiB 1760k https | av01.0.08M.08 1760k video only          1080p, mp4_dash
137     mp4   1920x1080   30    |  216.45MiB 2851k https | avc1.640028   2851k video only          1080p, mp4_dash
248     webm  1920x1080   30    |  122.86MiB 1618k https | vp9           1618k video only          1080p, webm_dash

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

This expression, at least, is failing:

Math.pow(3, 5) + new Date('1970-01-01T08:01:42.000+08:00') / 1000 * -239 - -24205

The correct value is 243 + (102000/1000)*(-239) + 24205 = 70 but yt-dl and probably yt-dlp get 24209:

Eval: _js_div 102000 1000
Eval: JS_mul 102.0 None
Eval: JS_sub 0.0 239
Eval: JS_sub -239 -24205
Eval: JS_add 243 23966

That is, 24209 = 243 + ((((102000/1000) * null) - 239) - 24205), considering that in JS null multiplies by 0 (yes!). The “lexical parser” is incorrectly failing to associate -239 with the result of 102000/1000 and making the RHS of the multiplication null instead.

New player 6f20102c:

λ yt-dlp_nightly.exe --ignore-config https://www.youtube.com/watch?v=32TU1ATIrjk -vU -F --extractor-args "youtube:player-client=web"
[debug] Command-line config: ['--ignore-config', 'https://www.youtube.com/watch?v=32TU1ATIrjk', '-vU', '-F', '--extractor-args', 'youtube:player-client=web']
[debug] Encodings: locale cp1251, fs utf-8, pref cp1251, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2023.04.19.042141 [8f0be90ec] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 6.0-full_build-www.gyan.dev (setts), ffprobe 6.0-full_build-www.gyan.dev, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-11.0.2
[debug] Proxy map: {}
[debug] Loaded 1801 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Available version: nightly@2023.04.19.042141, Current version: nightly@2023.04.19.042141
Current Build Hash: fdff0333689768f11466b1c8fde05c470a48aa9fef482d3f9ed58ae4083ec69b
yt-dlp is up to date (nightly@2023.04.19.042141)
[youtube] Extracting URL: https://www.youtube.com/watch?v=32TU1ATIrjk
[youtube] 32TU1ATIrjk: Downloading webpage
[youtube] 32TU1ATIrjk: Downloading player 6f20102c
[debug] Saving youtube-nsig.6f20102c to cache
WARNING: [youtube] 32TU1ATIrjk: Native nsig extraction failed: Trying with PhantomJS
         n = bHbfoOorqVPh3J ; player = https://www.youtube.com/s/player/6f20102c/player_ias.vflset/en_US/base.js
[debug] [youtube] Signature function returned an exception; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
[youtube] 32TU1ATIrjk: Executing signature code
[debug] [youtube] PhantomJS command line: phantomjs "--ssl-protocol=any" "C:\Temp\tmpw1ptwsnw"
[debug] [youtube] Decrypted nsig bHbfoOorqVPh3J => jtv4awXd4Uxy7w
[debug] Loading youtube-nsig.6f20102c from cache
WARNING: [youtube] 32TU1ATIrjk: Native nsig extraction failed: Trying with PhantomJS
         n = 715xvBdpBOUmT9 ; player = https://www.youtube.com/s/player/6f20102c/player_ias.vflset/en_US/base.js
[youtube] 32TU1ATIrjk: Executing signature code
[debug] [youtube] PhantomJS command line: phantomjs "--ssl-protocol=any" "C:\Temp\tmpcwn70fqu"
[debug] [youtube] Decrypted nsig 715xvBdpBOUmT9 => a5BfIQLLNe202w
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[info] Available formats for 32TU1ATIrjk:
ID  EXT   RESOLUTION FPS CH │   FILESIZE   TBR PROTO │ VCODEC        VBR ACODEC      ABR ASR MORE INFO
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb2 mhtml 48x27        0    │                  mhtml │ images                                storyboard
sb1 mhtml 80x45        0    │                  mhtml │ images                                storyboard
sb0 mhtml 160x90       0    │                  mhtml │ images                                storyboard
249 webm  audio only      2 │    6.20MiB   51k https │ audio only        opus        51k 48k low, WEB, webm_dash
250 webm  audio only      2 │    7.99MiB   66k https │ audio only        opus        66k 48k low, WEB, webm_dash
140 m4a   audio only      2 │   15.79MiB  129k https │ audio only        mp4a.40.2  129k 44k medium, WEB, m4a_dash
251 webm  audio only      2 │   14.59MiB  120k https │ audio only        opus       120k 48k medium, WEB, webm_dash
160 mp4   256x144     30    │    8.34MiB   68k https │ avc1.4d400c   68k video only          144p, WEB, mp4_dash
278 webm  256x144     30    │    8.14MiB   67k https │ vp9           67k video only          144p, WEB, webm_dash
133 mp4   426x240     30    │   18.14MiB  149k https │ avc1.4d4015  149k video only          240p, WEB, mp4_dash
242 webm  426x240     30    │   13.14MiB  108k https │ vp9          108k video only          240p, WEB, webm_dash
134 mp4   640x360     30    │   35.35MiB  290k https │ avc1.4d401e  290k video only          360p, WEB, mp4_dash
18  mp4   640x360     30  2 │   47.35MiB  388k https │ avc1.42001E  388k mp4a.40.2    0k 44k 360p, WEB
243 webm  640x360     30    │   22.61MiB  185k https │ vp9          185k video only          360p, WEB, webm_dash
135 mp4   854x480     30    │   62.75MiB  515k https │ avc1.4d401f  515k video only          480p, WEB, mp4_dash
244 webm  854x480     30    │   37.46MiB  307k https │ vp9          307k video only          480p, WEB, webm_dash
22  mp4   1280x720    30  2 │ ~138.57MiB 1110k https │ avc1.64001F 1110k mp4a.40.2    0k 44k 720p, WEB
136 mp4   1280x720    30    │  119.66MiB  981k https │ avc1.64001f  981k video only          720p, WEB, mp4_dash
247 webm  1280x720    30    │   70.62MiB  579k https │ vp9          579k video only          720p, WEB, webm_dash
137 mp4   1920x1080   30    │  229.41MiB 1882k https │ avc1.640028 1882k video only          1080p, WEB, mp4_dash
248 webm  1920x1080   30    │  112.90MiB  926k https │ vp9          926k video only          1080p, WEB, webm_dash
271 webm  2560x1440   30    │  375.37MiB 3079k https │ vp9         3079k video only          1440p, WEB, webm_dash
313 webm  3840x2160   30    │  765.04MiB 6275k https │ vp9         6275k video only          2160p, WEB, webm_dash

https://github.com/dirkf/youtube-dl/commit/211cbfd5d46025a8e4d8f9f3d424aaada4698974 resolves this for yt-dl, but the operator code is slightly different for yt-dlp.

Ofc a proper precedence-based expression evaluator would be better.

In case anyone needs it right now, the yt-dl version of js_interp.py will run in yt-dlp (maybe slower than the native version) if these definitions are added in place of the “compat” versions:

zip_longest = itertools.zip_longest
from collections import ChainMap

Same issue: https://github.com/ytdl-org/youtube-dl/issues/32066

Correct answers, according to Mozilla JS:

lE8DhoDmKqnmJJ -> pJTTX6XyJP2BYw 715xvBdpBOUmT9 -> a5BfIQLLNe202w

However, yt-dl is now being sent player d87d581f, which can be processed successfully, while yt-dlp is still getting 6f20102c (obvs, this changed just when I’d instrumented yt-dl to debug the issue).

@anunasica is not on master. The player works fine for me

97ea7458

It works in master. It breaks native nsig extraction in 2023.01.06 for the same reason as player dac945fd: an if statement in one of the array’s functions, which is handled by 8b008d62544b82e24a0ba36c30e8e51855d93419

Is there another player that can be used to workaround this?

I highly doubt it, because yt-dlp has to use whichever player youtube.com is using, and youtube.com seems to be using cfa9e7cb 100% of the time now (excluding music videos)

That said, even if you see that warning, it only affects a few formats (not the default ones) so it won’t affect regular users*. Super users can use --list-formats to pick formats that aren’t throttled (you’ll know if it’s throttled, because it says THROTTLED in all caps)

*Excluding age-restricted videos, which are currently always throttled. I found a complicated workaround though, so I’ll post instructions later

PS: I apologise if anyone finds my definition of “regular users” condescending, I’m just trying to address everyone following this issue at the same time

Player cfa9e7cb wants to do false << NaN. NaN should be zeroised (!) but isn’t.