|
|
|
@ -1623,15 +1623,22 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|
|
|
|
nfunc, idx = re.match(target, nfunc_and_idx).group('nfunc', 'idx')
|
|
|
|
|
if not idx:
|
|
|
|
|
return nfunc
|
|
|
|
|
|
|
|
|
|
VAR_RE_TMPL = r'var\s+%s\s*=\s*(?P<name>\[(?P<alias>%s)\])[;,]'
|
|
|
|
|
note = 'Initial JS player n function {0} (%s[%s])' % (nfunc, idx)
|
|
|
|
|
|
|
|
|
|
def search_function_code(needle, group):
|
|
|
|
|
return self._search_regex(
|
|
|
|
|
VAR_RE_TMPL % (re.escape(nfunc), needle), jscode,
|
|
|
|
|
note.format(group), group=group)
|
|
|
|
|
|
|
|
|
|
if int_or_none(idx) == 0:
|
|
|
|
|
real_nfunc = self._search_regex(
|
|
|
|
|
r'var %s\s*=\s*\[([a-zA-Z_$][\w$]*)\];' % (re.escape(nfunc), ), jscode,
|
|
|
|
|
'Initial JS player n function alias ({nfunc}[{idx}])'.format(**locals()))
|
|
|
|
|
real_nfunc = search_function_code(r'[a-zA-Z_$][\w$]*', group='alias')
|
|
|
|
|
if real_nfunc:
|
|
|
|
|
return real_nfunc
|
|
|
|
|
return self._parse_json(self._search_regex(
|
|
|
|
|
r'var %s\s*=\s*(\[.+?\]);' % (re.escape(nfunc), ), jscode,
|
|
|
|
|
'Initial JS player n function name ({nfunc}[{idx}])'.format(**locals())), nfunc, transform_source=js_to_json)[int(idx)]
|
|
|
|
|
return self._parse_json(
|
|
|
|
|
search_function_code('.+?', group='name'),
|
|
|
|
|
nfunc, transform_source=js_to_json)[int(idx)]
|
|
|
|
|
|
|
|
|
|
def _extract_n_function(self, video_id, player_url):
|
|
|
|
|
player_id = self._extract_player_info(player_url)
|
|
|
|
|