mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 09:21:27 +01:00
Compare commits
No commits in common. "6ebd484c9c03228fa42c565427d7df7095dd410a" and "13ec703a702f58510eb25db94dd046c37bfa826a" have entirely different histories.
6ebd484c9c
...
13ec703a70
|
@ -6,6 +6,7 @@ from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
|
qualities,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
|
@ -44,12 +45,11 @@ class NovaEmbedIE(InfoExtractor):
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
has_drm = False
|
drm_formats = []
|
||||||
duration = None
|
duration = None
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
def process_format_list(format_list, format_id=""):
|
def process_format_list(format_list, format_id=""):
|
||||||
nonlocal formats, has_drm
|
|
||||||
if not isinstance(format_list, list):
|
if not isinstance(format_list, list):
|
||||||
format_list = [format_list]
|
format_list = [format_list]
|
||||||
for format_dict in format_list:
|
for format_dict in format_list:
|
||||||
|
@ -57,7 +57,7 @@ class NovaEmbedIE(InfoExtractor):
|
||||||
continue
|
continue
|
||||||
if (not self.get_param('allow_unplayable_formats')
|
if (not self.get_param('allow_unplayable_formats')
|
||||||
and traverse_obj(format_dict, ('drm', 'keySystem'))):
|
and traverse_obj(format_dict, ('drm', 'keySystem'))):
|
||||||
has_drm = True
|
drm_formats.append(format_dict)
|
||||||
continue
|
continue
|
||||||
format_url = url_or_none(format_dict.get('src'))
|
format_url = url_or_none(format_dict.get('src'))
|
||||||
format_type = format_dict.get('type')
|
format_type = format_dict.get('type')
|
||||||
|
@ -77,25 +77,63 @@ class NovaEmbedIE(InfoExtractor):
|
||||||
'url': format_url,
|
'url': format_url,
|
||||||
})
|
})
|
||||||
|
|
||||||
player = self._search_json(
|
player = self._parse_json(
|
||||||
r'player:', webpage, 'player', video_id, fatal=False, end_pattern=r';\s*</script>')
|
self._search_regex(
|
||||||
|
r'player:\s*(?P<json>.*?)}\s*;?\s*</script>',
|
||||||
|
webpage, 'player', default='{}', flags=re.DOTALL, group='json'), video_id, fatal=False)
|
||||||
if player:
|
if player:
|
||||||
for src in traverse_obj(player, ('lib', 'source', 'sources', ...)):
|
for src in traverse_obj(player, ('lib', 'source', 'sources'), default=[]):
|
||||||
process_format_list(src)
|
process_format_list(src)
|
||||||
duration = traverse_obj(player, ('sourceInfo', 'duration', {int_or_none}))
|
duration = int_or_none(traverse_obj(player, ('sourceInfo', 'duration')))
|
||||||
if not formats and not has_drm:
|
if not formats and not drm_formats:
|
||||||
# older code path, in use before August 2023
|
|
||||||
player = self._parse_json(
|
player = self._parse_json(
|
||||||
self._search_regex(
|
self._search_regex(
|
||||||
(r'(?:(?:replacePlaceholders|processAdTagModifier).*?:\s*)?(?:replacePlaceholders|processAdTagModifier)\s*\(\s*(?P<json>{.*?})\s*\)(?:\s*\))?\s*,',
|
(r'(?:(?:replacePlaceholders|processAdTagModifier).*?:\s*)?(?:replacePlaceholders|processAdTagModifier)\s*\(\s*(?P<json>{.*?})\s*\)(?:\s*\))?\s*,',
|
||||||
r'Player\.init\s*\([^,]+,(?P<cndn>\s*\w+\s*\?)?\s*(?P<json>{(?(cndn).+?|.+)})\s*(?(cndn):|,\s*{.+?}\s*\)\s*;)'),
|
r'Player\.init\s*\([^,]+,(?P<cndn>\s*\w+\s*\?)?\s*(?P<json>{(?(cndn).+?|.+)})\s*(?(cndn):|,\s*{.+?}\s*\)\s*;)'),
|
||||||
webpage, 'player', group='json'), video_id)
|
webpage, 'player', default='{}', group='json'), video_id, fatal=False)
|
||||||
if player:
|
if player:
|
||||||
for format_id, format_list in player['tracks'].items():
|
for format_id, format_list in player['tracks'].items():
|
||||||
process_format_list(format_list, format_id)
|
process_format_list(format_list, format_id)
|
||||||
duration = int_or_none(player.get('duration'))
|
duration = int_or_none(player.get('duration'))
|
||||||
|
else:
|
||||||
|
# Old path, not actual as of 08.04.2020
|
||||||
|
bitrates = self._parse_json(
|
||||||
|
self._search_regex(
|
||||||
|
r'(?s)(?:src|bitrates)\s*=\s*({.+?})\s*;', webpage, 'formats'),
|
||||||
|
video_id, transform_source=js_to_json)
|
||||||
|
|
||||||
if not formats and has_drm:
|
QUALITIES = ('lq', 'mq', 'hq', 'hd')
|
||||||
|
quality_key = qualities(QUALITIES)
|
||||||
|
|
||||||
|
for format_id, format_list in bitrates.items():
|
||||||
|
if not isinstance(format_list, list):
|
||||||
|
format_list = [format_list]
|
||||||
|
for format_url in format_list:
|
||||||
|
format_url = url_or_none(format_url)
|
||||||
|
if not format_url:
|
||||||
|
continue
|
||||||
|
if format_id == 'hls':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
format_url, video_id, ext='mp4',
|
||||||
|
entry_protocol='m3u8_native', m3u8_id='hls',
|
||||||
|
fatal=False))
|
||||||
|
continue
|
||||||
|
f = {
|
||||||
|
'url': format_url,
|
||||||
|
}
|
||||||
|
f_id = format_id
|
||||||
|
for quality in QUALITIES:
|
||||||
|
if '%s.mp4' % quality in format_url:
|
||||||
|
f_id += '-%s' % quality
|
||||||
|
f.update({
|
||||||
|
'quality': quality_key(quality),
|
||||||
|
'format_note': quality.upper(),
|
||||||
|
})
|
||||||
|
break
|
||||||
|
f['format_id'] = f_id
|
||||||
|
formats.append(f)
|
||||||
|
|
||||||
|
if not formats and drm_formats:
|
||||||
self.report_drm(video_id)
|
self.report_drm(video_id)
|
||||||
|
|
||||||
title = self._og_search_title(
|
title = self._og_search_title(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user