-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
From yt-dl commit 48416bc
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
dict_get, | ||
float_or_none, | ||
int_or_none, | ||
js_to_json, | ||
mimetype2ext, | ||
parse_codecs, | ||
parse_duration, | ||
|
@@ -1391,9 +1392,16 @@ def _extract_player_url(self, webpage): | |
# 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 | ||
def _extract_n_function_name(self, jscode): | ||
return self._search_regex( | ||
(r'\.get\("n"\)\)&&\(b=(?P<nfunc>[a-zA-Z0-9$]{3})\([a-zA-Z0-9]\)',), | ||
jscode, 'Initial JS player n function name', group='nfunc') | ||
target = r'(?P<nfunc>[a-zA-Z0-9$]{3})(?:\[(?P<idx>\d+)\])?' | ||
nfunc_and_idx = self._search_regex( | ||
r'\.get\("n"\)\)&&\(b=(%s)\([a-zA-Z0-9]\)' % (target, ), | ||
jscode, 'Initial JS player n function name') | ||
nfunc, idx = re.match(target, nfunc_and_idx).group('nfunc', 'idx') | ||
if not idx: | ||
return nfunc | ||
return self._parse_json(self._search_regex( | ||
r'var %s\s*=\s*(\[.+?\]);' % (nfunc, ), jscode, | ||
'Initial JS player n function list ({nfunc}[{idx}])'.format(**locals())), nfunc, transform_source=js_to_json)[int(idx)] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dirkf
Author
Contributor
|
||
|
||
def _extract_n_function(self, video_id, player_url): | ||
player_id = self._extract_player_info(player_url) | ||
|
1 comment
on commit 1e67756
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. so many talented, bright folks to thank. God bless you all. We are in awe of you.
bruh