mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 01:02:13 +01:00
[plutotv] Extract subtitles from manifests
This commit is contained in:
parent
c28cfda81f
commit
7700b37f39
1 changed files with 19 additions and 15 deletions
|
@ -78,9 +78,8 @@ class PlutoTVIE(InfoExtractor):
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _to_ad_free_formats(self, video_id, formats):
|
def _to_ad_free_formats(self, video_id, formats, subtitles):
|
||||||
ad_free_formats = []
|
ad_free_formats, ad_free_subtitles, m3u8_urls = [], {}, set()
|
||||||
m3u8_urls = set()
|
|
||||||
for format in formats:
|
for format in formats:
|
||||||
res = self._download_webpage(
|
res = self._download_webpage(
|
||||||
format.get('url'), video_id, note='Downloading m3u8 playlist',
|
format.get('url'), video_id, note='Downloading m3u8 playlist',
|
||||||
|
@ -96,27 +95,32 @@ def _to_ad_free_formats(self, video_id, formats):
|
||||||
compat_urlparse.urljoin(first_segment_url.group(1), '0-end/master.m3u8'))
|
compat_urlparse.urljoin(first_segment_url.group(1), '0-end/master.m3u8'))
|
||||||
|
|
||||||
for m3u8_url in m3u8_urls:
|
for m3u8_url in m3u8_urls:
|
||||||
ad_free_formats.extend(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
self._extract_m3u8_formats(
|
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)
|
||||||
m3u8_url, video_id, 'mp4', 'm3u8_native',
|
ad_free_formats.extend(fmts)
|
||||||
m3u8_id='hls', fatal=False))
|
ad_free_subtitles = self._merge_subtitles(ad_free_subtitles, subs)
|
||||||
self._sort_formats(ad_free_formats)
|
return ad_free_formats, ad_free_subtitles
|
||||||
return ad_free_formats
|
|
||||||
|
|
||||||
def _get_video_info(self, video_json, slug, series_name=None):
|
def _get_video_info(self, video_json, slug, series_name=None):
|
||||||
video_id = video_json.get('_id', slug)
|
video_id = video_json.get('_id', slug)
|
||||||
formats = []
|
formats, subtitles = [], {}
|
||||||
for video_url in try_get(video_json, lambda x: x['stitched']['urls'], list) or []:
|
for video_url in try_get(video_json, lambda x: x['stitched']['urls'], list) or []:
|
||||||
if video_url.get('type') != 'hls':
|
if video_url.get('type') != 'hls':
|
||||||
continue
|
continue
|
||||||
url = url_or_none(video_url.get('url'))
|
url = url_or_none(video_url.get('url'))
|
||||||
formats.extend(
|
|
||||||
self._extract_m3u8_formats(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
url, video_id, 'mp4', 'm3u8_native',
|
url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)
|
||||||
m3u8_id='hls', fatal=False))
|
formats.extend(fmts)
|
||||||
|
subtitles = self._merge_subtitles(subtitles, subs)
|
||||||
|
|
||||||
|
formats, subtitles = self._to_ad_free_formats(video_id, formats, subtitles)
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'formats': self._to_ad_free_formats(video_id, formats),
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
'title': video_json.get('name'),
|
'title': video_json.get('name'),
|
||||||
'description': video_json.get('description'),
|
'description': video_json.get('description'),
|
||||||
'duration': float_or_none(video_json.get('duration'), scale=1000),
|
'duration': float_or_none(video_json.get('duration'), scale=1000),
|
||||||
|
|
Loading…
Reference in a new issue