mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
This commit is contained in:
parent
f41347260c
commit
0164cd5dac
1 changed files with 8 additions and 3 deletions
|
@ -17,6 +17,7 @@
|
||||||
determine_ext,
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
NO_DEFAULT,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
remove_quotes,
|
remove_quotes,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
|
@ -227,9 +228,9 @@ def dl_webpage(platform):
|
||||||
else:
|
else:
|
||||||
thumbnail, duration = [None] * 2
|
thumbnail, duration = [None] * 2
|
||||||
|
|
||||||
def extract_js_vars(webpage, pattern, fatal=True):
|
def extract_js_vars(webpage, pattern, default=NO_DEFAULT):
|
||||||
assignments = self._search_regex(
|
assignments = self._search_regex(
|
||||||
pattern, webpage, 'encoded url', fatal=fatal)
|
pattern, webpage, 'encoded url', default=default)
|
||||||
if not assignments:
|
if not assignments:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -270,11 +271,15 @@ def add_video_url(video_url):
|
||||||
FORMAT_PREFIXES = ('media', 'quality')
|
FORMAT_PREFIXES = ('media', 'quality')
|
||||||
js_vars = extract_js_vars(
|
js_vars = extract_js_vars(
|
||||||
webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES),
|
webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES),
|
||||||
fatal=False)
|
default=None)
|
||||||
if js_vars:
|
if js_vars:
|
||||||
for key, format_url in js_vars.items():
|
for key, format_url in js_vars.items():
|
||||||
if any(key.startswith(p) for p in FORMAT_PREFIXES):
|
if any(key.startswith(p) for p in FORMAT_PREFIXES):
|
||||||
add_video_url(format_url)
|
add_video_url(format_url)
|
||||||
|
if not video_urls and re.search(
|
||||||
|
r'<[^>]+\bid=["\']lockedPlayer', webpage):
|
||||||
|
raise ExtractorError(
|
||||||
|
'Video %s is locked' % video_id, expected=True)
|
||||||
|
|
||||||
if not video_urls:
|
if not video_urls:
|
||||||
js_vars = extract_js_vars(
|
js_vars = extract_js_vars(
|
||||||
|
|
Loading…
Reference in a new issue