youtube-dl: youtube_dl.utils.ExtractorError: Could not find JS function 'na'
Checklist
- I’m reporting a broken site support issue
- I’ve verified that I’m running youtube-dl version 2021.06.06
- 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
$ youtube-dl --verbose https://youtu.be/nXPyDlvZ1oQ
[debug] System config: []
[debug] User config: ['--format', 'bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best', '--merge-output-format', 'mp4', '-o', '/data/data/com.termux/files/home/storage/dcim/Camera/%(extractor_key)s-%(uploader)s-%(title)s-%(id)s.%(ext)s', '--no-mtime']
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://youtu.be/nXPyDlvZ1oQ']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.9.1 (CPython) - Linux-4.14.190-22338387-abN975USQS7FUI6-aarch64-with-libc
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1
[debug] Proxy map: {}
[youtube] nXPyDlvZ1oQ: Downloading webpage
[youtube] nXPyDlvZ1oQ: Downloading player 204bfffb
ERROR: Signature extraction failed: Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1348, in _decrypt_signature
func = self._extract_signature_function(
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1262, in _extract_signature_function
res = self._parse_sig_js(code)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1331, in _parse_sig_js
initial_function = jsi.extract_function(funcname)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/jsinterp.py", line 245, in extract_function
raise ExtractorError('Could not find JS function %r' % funcname)
youtube_dl.utils.ExtractorError: Could not find JS function 'na'; 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.
(caused by ExtractorError("Could not find JS function 'na'; 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.")); 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 "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1348, in _decrypt_signature
func = self._extract_signature_function(
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1262, in _extract_signature_function
res = self._parse_sig_js(code)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1331, in _parse_sig_js
initial_function = jsi.extract_function(funcname)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/jsinterp.py", line 245, in extract_function
raise ExtractorError('Could not find JS function %r' % funcname)
youtube_dl.utils.ExtractorError: Could not find JS function 'na'; 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 "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1348, in _decrypt_signature
func = self._extract_signature_function(
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1262, in _extract_signature_function
res = self._parse_sig_js(code)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1331, in _parse_sig_js
initial_function = jsi.extract_function(funcname)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/jsinterp.py", line 245, in extract_function
raise ExtractorError('Could not find JS function %r' % funcname)
youtube_dl.utils.ExtractorError: Could not find JS function 'na'; 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.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
return func(self, *args, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py", line 836, in __extract_info
ie_result = ie.extract(url)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/common.py", line 534, in extract
ie_result = self._real_extract(url)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1623, in _real_extract
signature = self._decrypt_signature(sc['s'][0], video_id, player_url)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1358, in _decrypt_signature
raise ExtractorError(
youtube_dl.utils.ExtractorError: Signature extraction failed: Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1348, in _decrypt_signature
func = self._extract_signature_function(
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1262, in _extract_signature_function
res = self._parse_sig_js(code)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py", line 1331, in _parse_sig_js
initial_function = jsi.extract_function(funcname)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/youtube_dl/jsinterp.py", line 245, in extract_function
raise ExtractorError('Could not find JS function %r' % funcname)
youtube_dl.utils.ExtractorError: Could not find JS function 'na'; 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.
(caused by ExtractorError("Could not find JS function 'na'; 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.")); 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.
Description
Trying to download video with either url or just video code returns the indicated error
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 78
- Comments: 89 (16 by maintainers)
Links to this issue
Commits related to this issue
- [youtube] Fix function signature parser (refs ytdl-org/#30363) — committed to lanegramling/youtube-dl by lanegramling 3 years ago
- Merge pull request #5 from lanegramling/fix-function-sig-parser [youtube] Fix function signature parser (refs ytdl-org/#30363) — committed to dirkf/youtube-dl by dirkf 3 years ago
- [youtube] Fix function signature parser (refs ytdl-org/#30363) — committed to dirkf/youtube-dl by lanegramling 3 years ago
- [youtube] Update signature function patterns (closes #30363) (#30366) — committed to ytdl-org/youtube-dl by lanegramling 3 years ago
- Merge commit '905d1d281ddfa5d183fc445010d350cefc6a58ec' into pr30184 * commit '905d1d281ddfa5d183fc445010d350cefc6a58ec': Implement n-param descrambling using JSInterp Refactor JSInterpreter._sep... — committed to gaming-hacker/youtube-dl by gaming-hacker 3 years ago
- Merge commit 'afaec67d45df19642eb4af230b506127af84ceff' into pr30184 * commit 'afaec67d45df19642eb4af230b506127af84ceff': Fixes 404 Issue Currently Present On XVIDEOS.COM release 2021.12.17 [Ch... — committed to gaming-hacker/youtube-dl by gaming-hacker 3 years ago
- [youtube] Fix function signature parser (refs ytdl-org/#30363) — committed to dirkf/youtube-dl by lanegramling 3 years ago
- [youtube] Update signature function patterns (closes #30363) (#30366) — committed to NoSuck/youtube-dl-1 by lanegramling 3 years ago
- [youtube] Update signature function patterns (closes #30363) (#30366) — committed to dirkf/youtube-dl by lanegramling 3 years ago
I have submitted a PR (#30366) that resolves this issue. It looks like no PRs have been merged to master in quite some time now, so if you’re really in a pinch to resolve this quickly, consider making the changes yourself to extractor/youtube.py in your local environments according to the changes in #30366 , as it is a simple fix (if you are brazen enough to do so).
The problem lies in that Youtube has apparently made some change in their base.js such that the signature parser is taking issue with changes evident in the function signature format. Most are 2 characters (as the regex in the parser assumes) but it seems that 2 characters can no longer be assumed after their update for these signatures. Just needed to tweak the regex to account for that, and I haven’t been able to replicate any of these issues since. You can see this for yourself by reviewing base.js at this link: https://www.youtube.com/s/player/850eb2bc/player_ias.vflset/en_US/base.js
Note that this finding was originally made in this PR for yt-dlp and is not mine: yt-dlp/yt-dlp#641. This fix for yt-dlp was spotted by @coletdjnz (good spot) in his earlier comment to this thread.
Official YT-DL working! Big big thanks for developers. Love u
For those that are struggling and are here for an easy fix as @lanegramling did a PR in the original repo, and forked it as well: (EDITED with https://github.com/ytdl-org/youtube-dl/issues/30363#issuecomment-995121012)
git clone --depth 1 --branch fix-function-sig-parser https://github.com/lanegramling/youtube-dl.git
cd youtube_dl
pip install -e .
youtube-dl {youtube_url}
the link to @lanegramling PR is wrong, to see what @lanegramling has changed to reapply to local files see https://github.com/ytdl-org/youtube-dl/pull/30366/commits/1a091687c248b62c2f0a6070519bd78417828746
It’s quite easy, only 4 lines need changing, all at one place. You just need a few commas in regex.
Looks like youtube-dl needs to update the signature function regex.
There is no issue in yt-dlp, seems like this was avoided by https://github.com/yt-dlp/yt-dlp/pull/641.
Back-porting them from yt-dlp works. Relevant code: https://github.com/yt-dlp/yt-dlp/blob/0bb322b9c0aebb7e0a93a5de1dbede4acdd10ff5/yt_dlp/extractor/youtube.py#L1828-L1845
Edit: Given the above patch by https://github.com/yt-dlp/yt-dlp/pull/641, it may be possible that future player js versions may work again (but also break again at times for the same reason) with existing code.
Correction to this helpful comment:
Yeah, I recommend to use yt-dlp or smthn like this, because there is no bug and creators support their creation and i use module in js (yt-dlp-exec) , which has no changes with old and good youtube-dl-exec.
See updated script below.
For the benefit of the impatient reader, here is how I applied the single file fix of PR #30366 to the lastest binary
youtube-dl
on Linux:Notes:
wget -O
(big Oh) and notwget -o
(small o).Update
Here is a
bash
(yes, you needbash
. Neitherdash
norksh
probably grok this) script to create ayoutube-dl.fixed
from PR #30184 (which apparently already includes PR #30366, sorry for me getting this detail wrong above). After this I get full speed, too (as fast as my cable can do):Thanks for this goes to all the contributers of youtube-dl!
Same issue, macOS Monterey
This was a good advice. The fork works well.
(although I am usually not a fan of using someone’s repo to promote another, in this case I feel people are desperate for a quick solution that may never come.)
Yes, possibly. But it is likely this will occur again.
Though tbh if you can I’d just switch your dependency to yt-dlp (it’s youtube-dl but actively maintained).
@dirkf Thanks for the hint and sorry for me getting it wrong at first. My bad English.
Updated my comment with a script which patches both files from the other PR.
To all others:
youtube-dl
and must reside in the current directory./youtube-dl.fixed
afterwards, as the script does not overwrite the preciousyoutube-dl
original.If only there were some way to organise a hodgepodge of random patches into a derivative project.
As your yt-dl is in
site-packages
, it’s not a Fedora issue (if the distro had installed it, it would be indist-packages
).You can apply the single file update over
/usr/lib/python3.10/site-packages/youtube_dl/extractor/youtube.py
.I switched to yt-dlp. One unexpected benefit: download speed is much better (youtube-dl got slower and slower in the last few months. I thought this was google throttling me and shrugged)
I just installed the latest version from pip and it works. Make sure you’ve updated yt-dlp.
This brings up an issue in Github. Some of the better programs have dozens, even hundreds, of branches. A system of grading the variants would be useful, at least an icon in the listing to indicate no change/activity in the branch.
I need a solution for my Discord bot written in python please help me with this issue
yes the same issue here, please fix this asap or someone show me the way how can i fix this
Real shame. It is a tool I use daily. No it is unfunctional for (probably) a long time
Give us a hint about what kind of installation you have and how updating it failed.
Damn, this is a mess. I can’t find any comment for a fix of youtube-dl installed with brew on macOS. Could someone point me to it?
Can anyone create a new repo for youtube_dl with fixes so that I can download updated file
I have posted the solution in this thread above. For now you will have to implement it yourself in your local environment. It is a simple change. No PRs have been merged to master in months, so we can’t really expect a fix to be merged through the official channels in any reasonable amount of time.
Same issue on Fedora 35: