Skip to content

Commit

Permalink
[extractor/youtube] Improve nsig function name extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan committed Jun 22, 2023
1 parent b4e0d75 commit cd810af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/test_youtube_signature.py
Expand Up @@ -159,6 +159,10 @@
'https://www.youtube.com/s/player/8c7583ff/player_ias.vflset/en_US/base.js',
'1wWCVpRR96eAmMI87L', 'KSkWAVv1ZQxC3A',
),
(
'https://www.youtube.com/s/player/b7910ca8/player_ias.vflset/en_US/base.js',
'_hXMCwMt9qE310D', 'LoZMgkkofRMCZQ',
),
]


Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/youtube.py
Expand Up @@ -3140,7 +3140,7 @@ def _extract_n_function_name(self, jscode):
return funcname

return json.loads(js_to_json(self._search_regex(
rf'var {re.escape(funcname)}\s*=\s*(\[.+?\]);', jscode,
rf'var {re.escape(funcname)}\s*=\s*(\[.+?\])[,;]', jscode,
f'Initial JS player n function list ({funcname}.{idx})')))[int(idx)]

def _extract_n_function_code(self, video_id, player_url):
Expand Down

0 comments on commit cd810af

Please sign in to comment.