Repository: ytdl-org/youtube-dl

Issue:
Does not work
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.youtube.com/watch?v=Uz3TV5PpAss']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.11.19
[debug] Python version 3.8.10 (CPython) - Linux-5.4.0-91-generic-x86_64-with-glibc2.29
[debug] exe versions: ffmpeg 4.2.4, ffprobe 4.2.4, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] Uz3TV5PpAss: Downloading webpage
[youtube] {18} signature length 106, html5 player 204bfffb
[youtube] Uz3TV5PpAss: Downloading player https://www.youtube.com/s/player/204bfffb/player_ias.vflset/en_US/base.js
ERROR: Signature extraction failed: Traceback (most recent call last):
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1226, in _decrypt_signature
    func = self._extract_signature_function(
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1127, in _extract_signature_function
    res = self._parse_sig_js(code)
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1202, in _parse_sig_js
    initial_function = jsi.extract_function(funcname)
  File "/home/kkbits/.local/lib/python3.8/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 "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1226, in _decrypt_signature
    func = self._extract_signature_function(
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1127, in _extract_signature_function
    res = self._parse_sig_js(code)
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1202, in _parse_sig_js
    initial_function = jsi.extract_function(funcname)
  File "/home/kkbits/.local/lib/python3.8/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 "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1226, in _decrypt_signature
    func = self._extract_signature_function(
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1127, in _extract_signature_function
    res = self._parse_sig_js(code)
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1202, in _parse_sig_js
    initial_function = jsi.extract_function(funcname)
  File "/home/kkbits/.local/lib/python3.8/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 "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/common.py", line 532, in extract
    ie_result = self._real_extract(url)
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1910, in _real_extract
    signature = self._decrypt_signature(
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1236, in _decrypt_signature
    raise ExtractorError(
youtube_dl.utils.ExtractorError: Signature extraction failed: Traceback (most recent call last):
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1226, in _decrypt_signature
    func = self._extract_signature_function(
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1127, in _extract_signature_function
    res = self._parse_sig_js(code)
  File "/home/kkbits/.local/lib/python3.8/site-packages/youtube_dl/extractor/youtube.py", line 1202, in _parse_sig_js
    initial_function = jsi.extract_function(funcname)
  File "/home/kkbits/.local/lib/python3.8/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.



Discussion:

Resolving patch:
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -1323,10 +1323,10 @@ def _parse_sig_js(self, jscode):
         funcname = self._search_regex(
             (r'\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
              r'\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
-             r'\bm=(?P<sig>[a-zA-Z0-9$]{2})\(decodeURIComponent\(h\.s\)\)',
-             r'\bc&&\(c=(?P<sig>[a-zA-Z0-9$]{2})\(decodeURIComponent\(c\)\)',
-             r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\)',
-             r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
+             r'\bm=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(h\.s\)\)',
+             r'\bc&&\(c=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(c\)\)',
+             r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\)',
+             r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
              r'(?P<sig>[a-zA-Z0-9$]+)\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
              # Obsolete patterns
              r'(["\'])signature\1\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',


Test patch: