youtube-dl: n-parameter: Unhandled exception in decode

Checklist

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

Verbose log

[2023-04-20 10:45:46,804 - INFO] Downloading Парибок Андрей. Искусство сопряженное с психотехнологиями. Трансляция состояний и намерений. (id 21922) from https://youtu.be/i2-ViOyC7Ek
[debug] Encodings: locale cp1251, fs utf-8, out utf-8, pref cp1251
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.10.5 (CPython) - Windows-10-10.0.19045-SP0
[debug] exe versions: ffmpeg 4.2.3, ffprobe 5.1.2-full_build-www.gyan.dev
[debug] Proxy map: {}
[youtube] i2-ViOyC7Ek: Downloading webpage
WARNING: [youtube] Unable to decode n-parameter: download likely to be throttled (Unhandled exception in decode; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.
org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output. Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\pypoetry\Cache\virtualenvs\wapatools-3SjGFAFe-py3.10\lib\site-packages\youtube_dl\extractor\youtube.py", line 1672, in _n_descramble
    raise ExtractorError('Unhandled exception in decode')
youtube_dl.utils.ExtractorError: Unhandled exception in decode; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call you
tube-dl with the --verbose flag and include its complete output.
)
[debug] Invoking downloader on 'https://rr3---sn-fpaq25g3-oa8l.googlevideo.com/videoplayback?expire=1681998348&ei=rO1AZOLpGMOM7ATZ17jIDQ&ip=109.104.175.34&id=o-AKknyKgyubMl4R9EHIXwjBdgPDw6dl3Tx7K0_vRY3z0R&itag=140&source=youtube
&requiressl=yes&mh=QJ&mm=31%2C29&mn=sn-fpaq25g3-oa8l%2Csn-3c27snel&ms=au%2Crdu&mv=m&mvi=3&pcm2cms=yes&pl=21&initcwndbps=1542500&vprv=1&mime=audio%2Fmp4&ns=6BAWLWBNpwisYfXPM4aWKiUM&gir=yes&clen=59473523&dur=3674.813&lmt=164976146
2988446&mt=1681976453&fvip=15&keepalive=yes&fexp=24007246&c=WEB&txp=1311224&n=3cemMzCD7mQvT9&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAMvN1Ck7ififLU9D
gB2gUEyMJIq-Chp90btXUIsM_4EXAiBrVtfI5tuSrr74nfCB0Bfc3CqJs4qb3O_CHCXnLgDnNA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgWPmhU0H_-_-em5QH0po1qzSn7vHNYSV8QH8FD5CUX00CIHTF3ofj_wY5cga1_z7
r_T4Gc4yi6z28HdeyCpBIeZBF'
[dashsegments] Total fragments: 6
[download] Destination: D:\au\youtube\Парибок Андрей. Искусство сопряженное с психотехнологиями. Трансляция состояний и намерений.-i2-ViOyC7Ek-20161004.m4a

Description

When attempting to download from Youtube, I get Unable to decode n-parameter: download likely to be throttled (Unhandled exception in decode error. Downloading happens at low speed ~50-80 Kib/s

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 33 (17 by maintainers)

Commits related to this issue

Most upvoted comments

It’s just that, currently, the player ID is only shown in the debug output when first downloading the player JS, and not when fetching from cache.

Coming soon (the above commit):

$ python -m youtube_dl -v -F 'i2-ViOyC7Ek'
[debug] System config: [u'--prefer-ffmpeg']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-F', u'i2-ViOyC7Ek']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: 211cbfd5d
[debug] Python version 2.7.18 (CPython) - Linux-4.4.0-210-generic-i686-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv 4.3, avprobe 4.3, ffmpeg 4.3, ffprobe 4.3
[debug] Proxy map: {}
[youtube] Extracting URL: i2-ViOyC7Ek
[youtube] i2-ViOyC7Ek: Downloading webpage
[debug] [youtube] Decrypted nsig crYhSJ5EIbtdN2OEP => jykH2eTdaP_Dqw
[debug] [youtube] Decrypted nsig cHQcRxq_Yj4Gi4qJ- => EKFC_eOif5yd2A
[info] Available formats for i2-ViOyC7Ek:
format code  extension  resolution note
249          webm       audio only tiny   47k , webm_dash container, opus @ 47k (48000Hz), 20.86MiB
250          webm       audio only tiny   59k , webm_dash container, opus @ 59k (48000Hz), 26.04MiB
251          webm       audio only tiny  117k , webm_dash container, opus @117k (48000Hz), 51.40MiB
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 56.72MiB
160          mp4        256x144    144p   38k , mp4_dash container, avc1.4d400c@  38k, 25fps, video only, 16.73MiB
278          webm       256x144    144p   62k , webm_dash container, vp9@  62k, 25fps, video only, 27.53MiB
242          webm       426x240    240p   78k , webm_dash container, vp9@  78k, 25fps, video only, 34.32MiB
133          mp4        426x240    240p   85k , mp4_dash container, avc1.4d4015@  85k, 25fps, video only, 37.27MiB
134          mp4        640x360    360p  131k , mp4_dash container, avc1.4d401e@ 131k, 25fps, video only, 57.58MiB
243          webm       640x360    360p  134k , webm_dash container, vp9@ 134k, 25fps, video only, 58.99MiB
244          webm       854x480    480p  208k , webm_dash container, vp9@ 208k, 25fps, video only, 91.29MiB
135          mp4        854x480    480p  289k , mp4_dash container, avc1.4d401e@ 289k, 25fps, video only, 126.78MiB
247          webm       1280x720   720p  440k , webm_dash container, vp9@ 440k, 25fps, video only, 192.94MiB
136          mp4        1280x720   720p  628k , mp4_dash container, avc1.4d401f@ 628k, 25fps, video only, 275.33MiB
248          webm       1920x1080  1080p  596k , webm_dash container, vp9@ 596k, 25fps, video only, 261.49MiB
137          mp4        1920x1080  1080p 2500k , mp4_dash container, avc1.640028@2500k, 25fps, video only, 1.07GiB
18           mp4        640x360    360p  260k , avc1.42001E@ 260k, 25fps, mp4a.40.2@  0k (44100Hz)
22           mp4        1280x720   720p  757k , avc1.64001F@ 757k, 25fps, mp4a.40.2@  0k (44100Hz) (best)
$

See #32292.

$ python3.9 ./devscripts/cli_to_api.py --no-cache-dir
{'cachedir': False}
$ 

Success:

$ python3.9 -m youtube_dl -v -F '3gbIsY-eOq0'
[debug] System config: ['--prefer-ffmpeg']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-F', '3gbIsY-eOq0']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: d0b1f995c
[debug] Python 3.9.16 (CPython 32bit) - Linux-4.4.0-210-generic-i686-with-glibc2.23 (OpenSSL 1.1.1t  7 Feb 2023, glibc 2.23)
[debug] exe versions: avconv 4.3, avprobe 4.3, ffmpeg 4.3, ffprobe 4.3
[debug] Proxy map: {}
[youtube] 3gbIsY-eOq0: Downloading webpage
> /home/df/Documents/src/youtube-dl/youtube_dl/extractor/youtube.py(1662)_n_descramble()
-> sig_id = ('nsig_value', n_param)
(Pdb) p player_url
'https://www.youtube.com/s/player/cfa9e7cb/player_ias.vflset/en_US/base.js'
(Pdb) c
[debug] [youtube] Decrypted nsig Ym5AQeQbA2N56kd-ov => PBcV05aInCFS6w
...
[debug] [youtube] Decrypted nsig gQQRhkv9X8BrpB06v6 => PUMGuyQl8dp_Ag
...
[info] Available formats for 3gbIsY-eOq0:
format code  extension  resolution note
249          webm       audio only tiny   51k , webm_dash container, opus  (48000Hz), 186.89KiB
250          webm       audio only tiny   60k , webm_dash container, opus  (48000Hz), 220.88KiB
251          webm       audio only tiny  113k , webm_dash container, opus  (48000Hz), 412.58KiB
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2 (44100Hz), 474.13KiB
160          mp4        144x256    144p   63k , mp4_dash container, avc1.4d400c, 25fps, video only, 231.75KiB
278          webm       144x256    144p   80k , webm_dash container, vp9, 25fps, video only, 294.58KiB
242          webm       240x426    240p  128k , webm_dash container, vp9, 25fps, video only, 468.80KiB
133          mp4        240x426    240p  141k , mp4_dash container, avc1.4d4015, 25fps, video only, 515.75KiB
243          webm       360x640    360p  224k , webm_dash container, vp9, 25fps, video only, 819.92KiB
134          mp4        360x640    360p  264k , mp4_dash container, avc1.4d401e, 25fps, video only, 965.64KiB
244          webm       480x854    480p  364k , webm_dash container, vp9, 25fps, video only, 1.30MiB
135          mp4        480x854    480p  588k , mp4_dash container, avc1.4d401e, 25fps, video only, 2.10MiB
247          webm       720x1280   720p  643k , webm_dash container, vp9, 25fps, video only, 2.29MiB
136          mp4        720x1280   720p 1117k , mp4_dash container, avc1.64001f, 25fps, video only, 3.98MiB
248          webm       1080x1920  1080p 1133k , webm_dash container, vp9, 25fps, video only, 4.04MiB
137          mp4        1080x1920  1080p 2039k , mp4_dash container, avc1.640028, 25fps, video only, 7.26MiB
18           mp4        270x480    240p  421k , avc1.42001E, 25fps, mp4a.40.2 (48000Hz), 1.50MiB
22           mp4        720x1280   720p 1246k , avc1.64001F, 25fps, mp4a.40.2 (44100Hz) (best)
$

The relevant change:

     return update_and_rename_wrapper
 
 
+_NaN = float('nan')
+
+
 def _js_bit_op(op):
 
     def zeroise(x):
-        return 0 if x in (None, JS_Undefined) else x
+        return 0 if x in (None, JS_Undefined, _NaN) else x
 
     @wraps_op(op)
     def wrapped(a, b):

Thank you, @dirkf !

Ok thanks again! ps: Commit 211cbfd5d fixes the problem.

Please try the brand new master code (#31530 provides updating instructions if you’re not just checking it out with git, but the unofficial nightly builds won’t be updated yet). Also, perhaps first, try --no-cache-dir and if that works --rm-cache-dir. The problem expression is in the player code that is processed correctly here.

Your URL is working fine here: hence the question.

You can just pull the jsinterp.py from my repo, or apply the diff, if you want to integrate this into your Python script ASAP.

Oh, I’m sorry. I’m actually using a script here, not the CLI, so the log is not cropped. But here are the options I use:

            "format": "bestaudio/best",
            "cookiefile": "D:\\Mega\\propagit\\running\\cookies.Work.txt",
            "outtmpl": f"{save_to_path}%(title)s-%(id)s-%(upload_date)s.%(ext)s",
            "writeinfotojson": True,
            "cachedir": "D:\\",
            "postprocessors": [
                {
                    'key': 'FFmpegExtractAudio',
                    'preferredcodec': 'mp3',
                    'preferredquality': '192',
                }
            ],
            "verbose": True
        }

And this happens to every video I try to download. Started yesterday.

Please post the whole log without cropping the top!

In this case, I can see that you’re trying to get the YT video with ID i2-ViOyC7Ek, but not what options you used. Anyhow, I can reproduce the issue and will investigate.