[extractor/youtube] Improve nsig function name extraction

This commit is contained in:
pukkandan 2023-06-22 13:23:31 +05:30
parent b4e0d75848
commit cd810afe2a
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
2 changed files with 5 additions and 1 deletions

View file

@ -159,6 +159,10 @@ _NSIG_TESTS = [
'https://www.youtube.com/s/player/8c7583ff/player_ias.vflset/en_US/base.js', 'https://www.youtube.com/s/player/8c7583ff/player_ias.vflset/en_US/base.js',
'1wWCVpRR96eAmMI87L', 'KSkWAVv1ZQxC3A', '1wWCVpRR96eAmMI87L', 'KSkWAVv1ZQxC3A',
), ),
(
'https://www.youtube.com/s/player/b7910ca8/player_ias.vflset/en_US/base.js',
'_hXMCwMt9qE310D', 'LoZMgkkofRMCZQ',
),
] ]

View file

@ -3140,7 +3140,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
return funcname return funcname
return json.loads(js_to_json(self._search_regex( 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)] f'Initial JS player n function list ({funcname}.{idx})')))[int(idx)]
def _extract_n_function_code(self, video_id, player_url): def _extract_n_function_code(self, video_id, player_url):