mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 19:52:11 +00:00
parent
b764dbe773
commit
a0068bd6be
1 changed files with 3 additions and 3 deletions
|
@ -1464,15 +1464,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
# 2. https://code.videolan.org/videolan/vlc/-/blob/4fb284e5af69aa9ac2100ccbdd3b88debec9987f/share/lua/playlist/youtube.lua#L116
|
# 2. https://code.videolan.org/videolan/vlc/-/blob/4fb284e5af69aa9ac2100ccbdd3b88debec9987f/share/lua/playlist/youtube.lua#L116
|
||||||
# 3. https://github.com/ytdl-org/youtube-dl/issues/30097#issuecomment-950157377
|
# 3. https://github.com/ytdl-org/youtube-dl/issues/30097#issuecomment-950157377
|
||||||
def _extract_n_function_name(self, jscode):
|
def _extract_n_function_name(self, jscode):
|
||||||
target = r'(?P<nfunc>[a-zA-Z0-9$]{3})(?:\[(?P<idx>\d+)\])?'
|
target = r'(?P<nfunc>[a-zA-Z_$][\w$]*)(?:\[(?P<idx>\d+)\])?'
|
||||||
nfunc_and_idx = self._search_regex(
|
nfunc_and_idx = self._search_regex(
|
||||||
r'\.get\("n"\)\)&&\(b=(%s)\([a-zA-Z0-9]\)' % (target, ),
|
r'\.get\("n"\)\)&&\(b=(%s)\([\w$]+\)' % (target, ),
|
||||||
jscode, 'Initial JS player n function name')
|
jscode, 'Initial JS player n function name')
|
||||||
nfunc, idx = re.match(target, nfunc_and_idx).group('nfunc', 'idx')
|
nfunc, idx = re.match(target, nfunc_and_idx).group('nfunc', 'idx')
|
||||||
if not idx:
|
if not idx:
|
||||||
return nfunc
|
return nfunc
|
||||||
return self._parse_json(self._search_regex(
|
return self._parse_json(self._search_regex(
|
||||||
r'var %s\s*=\s*(\[.+?\]);' % (nfunc, ), jscode,
|
r'var %s\s*=\s*(\[.+?\]);' % (re.escape(nfunc), ), jscode,
|
||||||
'Initial JS player n function list ({nfunc}[{idx}])'.format(**locals())), nfunc, transform_source=js_to_json)[int(idx)]
|
'Initial JS player n function list ({nfunc}[{idx}])'.format(**locals())), nfunc, transform_source=js_to_json)[int(idx)]
|
||||||
|
|
||||||
def _extract_n_function(self, video_id, player_url):
|
def _extract_n_function(self, video_id, player_url):
|
||||||
|
|
Loading…
Reference in a new issue