[youtube] Fix n-sig for player e06dea74

This commit is contained in:
pukkandan 2022-02-01 08:10:19 +05:30
parent 6a0546e313
commit 48416bc4a8
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
2 changed files with 13 additions and 3 deletions

View file

@ -86,6 +86,10 @@
'https://www.youtube.com/s/player/8040e515/player_ias.vflset/en_US/base.js', 'https://www.youtube.com/s/player/8040e515/player_ias.vflset/en_US/base.js',
'wvOFaY-yjgDuIEg5', 'HkfBFDHmgw4rsw', 'wvOFaY-yjgDuIEg5', 'HkfBFDHmgw4rsw',
), ),
(
'https://www.youtube.com/s/player/e06dea74/player_ias.vflset/en_US/base.js',
'AiuodmaDDYw8d3y4bf', 'ankd8eza2T6Qmw',
),
] ]

View file

@ -42,6 +42,7 @@
int_or_none, int_or_none,
is_html, is_html,
join_nonempty, join_nonempty,
js_to_json,
mimetype2ext, mimetype2ext,
network_exceptions, network_exceptions,
NO_DEFAULT, NO_DEFAULT,
@ -2420,9 +2421,14 @@ def _decrypt_nsig(self, s, video_id, player_url):
raise ExtractorError(traceback.format_exc(), cause=e, video_id=video_id) raise ExtractorError(traceback.format_exc(), cause=e, video_id=video_id)
def _extract_n_function_name(self, jscode): def _extract_n_function_name(self, jscode):
return self._search_regex( nfunc, idx = self._search_regex(
(r'\.get\("n"\)\)&&\(b=(?P<nfunc>[a-zA-Z0-9$]{3})\([a-zA-Z0-9]\)',), r'\.get\("n"\)\)&&\(b=(?P<nfunc>[a-zA-Z0-9$]{3})(\[(?P<idx>\d+)\])?\([a-zA-Z0-9]\)',
jscode, 'Initial JS player n function name', group='nfunc') jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
if not idx:
return nfunc
return json.loads(js_to_json(self._search_regex(
rf'var {nfunc}\s*=\s*(\[.+?\]);', jscode,
f'Initial JS player n function list ({nfunc}.{idx})')))[int(idx)]
def _extract_n_function(self, video_id, player_url): def _extract_n_function(self, video_id, player_url):
player_id = self._extract_player_info(player_url) player_id = self._extract_player_info(player_url)