mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
[vrv] extract dash formats and subtitles
This commit is contained in:
parent
e9137224b3
commit
afa0200bf0
|
@ -112,21 +112,41 @@ class VRVIE(VRVBaseIE):
|
||||||
|
|
||||||
audio_locale = streams_json.get('audio_locale')
|
audio_locale = streams_json.get('audio_locale')
|
||||||
formats = []
|
formats = []
|
||||||
for stream_id, stream in streams_json.get('streams', {}).get('adaptive_hls', {}).items():
|
for stream_type, streams in streams_json.get('streams', {}).items():
|
||||||
stream_url = stream.get('url')
|
if stream_type in ('adaptive_hls', 'adaptive_dash'):
|
||||||
if not stream_url:
|
for stream in streams.values():
|
||||||
continue
|
stream_url = stream.get('url')
|
||||||
stream_id = stream_id or audio_locale
|
if not stream_url:
|
||||||
m3u8_formats = self._extract_m3u8_formats(
|
continue
|
||||||
stream_url, video_id, 'mp4', m3u8_id=stream_id,
|
stream_id = stream.get('hardsub_locale') or audio_locale
|
||||||
note='Downloading %s m3u8 information' % stream_id,
|
format_id = '%s-%s' % (stream_type.split('_')[1], stream_id)
|
||||||
fatal=False)
|
if stream_type == 'adaptive_hls':
|
||||||
if audio_locale:
|
adaptive_formats = self._extract_m3u8_formats(
|
||||||
for f in m3u8_formats:
|
stream_url, video_id, 'mp4', m3u8_id=format_id,
|
||||||
f['language'] = audio_locale
|
note='Downloading %s m3u8 information' % stream_id,
|
||||||
formats.extend(m3u8_formats)
|
fatal=False)
|
||||||
|
else:
|
||||||
|
adaptive_formats = self._extract_mpd_formats(
|
||||||
|
stream_url, video_id, mpd_id=format_id,
|
||||||
|
note='Downloading %s MPD information' % stream_id,
|
||||||
|
fatal=False)
|
||||||
|
if audio_locale:
|
||||||
|
for f in adaptive_formats:
|
||||||
|
if f.get('acodec') != 'none':
|
||||||
|
f['language'] = audio_locale
|
||||||
|
formats.extend(adaptive_formats)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
subtitles = {}
|
||||||
|
for subtitle in streams_json.get('subtitles', {}).values():
|
||||||
|
subtitle_url = subtitle.get('url')
|
||||||
|
if not subtitle_url:
|
||||||
|
continue
|
||||||
|
subtitles.setdefault(subtitle.get('locale', 'en-US'), []).append({
|
||||||
|
'url': subtitle_url,
|
||||||
|
'ext': subtitle.get('format', 'ass'),
|
||||||
|
})
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
for thumbnail in video_data.get('images', {}).get('thumbnails', []):
|
for thumbnail in video_data.get('images', {}).get('thumbnails', []):
|
||||||
thumbnail_url = thumbnail.get('source')
|
thumbnail_url = thumbnail.get('source')
|
||||||
|
@ -142,6 +162,7 @@ class VRVIE(VRVBaseIE):
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'description': video_data.get('description'),
|
'description': video_data.get('description'),
|
||||||
'duration': float_or_none(video_data.get('duration_ms'), 1000),
|
'duration': float_or_none(video_data.get('duration_ms'), 1000),
|
||||||
|
|
Loading…
Reference in a new issue