mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-12 18:07:14 +08:00
[seznamzpravy] Parse HLS and DASH
Includes extension of generic MPD extractor and few more fixes per dstftw.
This commit is contained in:
parent
4d8729978f
commit
defcd753ef
@ -1979,6 +1979,15 @@ class InfoExtractor(object):
|
||||
})
|
||||
segment_index += 1
|
||||
representation_ms_info['fragments'] = fragments
|
||||
elif 'segment_urls' in representation_ms_info:
|
||||
# Segment URLs with no SegmentTimeline
|
||||
# Example: https://www.seznam.cz/zpravy/clanek/cesko-zasahne-vitr-o-sile-vichrice-muze-byt-i-zivotu-nebezpecny-39091
|
||||
fragments = []
|
||||
for segment_url in representation_ms_info['segment_urls']:
|
||||
fragments.append({
|
||||
location_key(segment_url): segment_url,
|
||||
})
|
||||
representation_ms_info['fragments'] = fragments
|
||||
# NB: MPD manifest may contain direct URLs to unfragmented media.
|
||||
# No fragments key is present in this case.
|
||||
if 'fragments' in representation_ms_info:
|
||||
|
@ -16,7 +16,9 @@ class SeznamZpravyIE(InfoExtractor):
|
||||
_TESTS = [{
|
||||
# video with SDN URL
|
||||
'url': 'https://www.seznam.cz/zpravy/clanek/jejich-svet-na-nas-utoci-je-lepsi-branit-se-na-jejich-pisecku-rika-reziser-a-major-v-zaloze-marhoul-35990',
|
||||
'md5': '855f9fed87bd93e48775d59671a3a3e3',
|
||||
'params': {'skip_download': True},
|
||||
# ^ this is here instead of 'file_minsize': 1586, which does not work because
|
||||
# test_download.py forces expected_minsize to at least 10k when test is running
|
||||
'info_dict': {
|
||||
'id': '35990',
|
||||
'ext': 'mp4',
|
||||
@ -37,21 +39,23 @@ class SeznamZpravyIE(InfoExtractor):
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
data = self._download_json(self._API_URL + 'v1/documents/' + video_id, video_id)
|
||||
title = data['captionTitle']
|
||||
|
||||
if 'video' in data['caption']:
|
||||
sdn_url = data['caption']['video']['sdn'] + self._MAGIC_SUFFIX
|
||||
else:
|
||||
sdn_url = self._download_json(data['caption']['liveStreamUrl'] + self._MAGIC_SUFFIX, video_id)['Location']
|
||||
|
||||
sdn_data = self._download_json(sdn_url, video_id)
|
||||
formats = []
|
||||
for fmt, fmtdata in self._download_json(sdn_url, video_id)['data']['mp4'].items():
|
||||
for fmt, fmtdata in sdn_data.get('data', {}).get('mp4', {}).items():
|
||||
relative_url = fmtdata.get('url')
|
||||
if not relative_url:
|
||||
continue
|
||||
|
||||
try:
|
||||
width, height = fmtdata.get('resolution')
|
||||
except TypeError:
|
||||
except (TypeError, ValueError):
|
||||
width, height = None, None
|
||||
|
||||
formats.append({
|
||||
@ -61,11 +65,20 @@ class SeznamZpravyIE(InfoExtractor):
|
||||
'url': urljoin(sdn_url, relative_url),
|
||||
})
|
||||
|
||||
playlists = sdn_data.get('pls', {})
|
||||
dash_rel_url = playlists.get('dash', {}).get('url')
|
||||
if dash_rel_url:
|
||||
formats.extend(self._extract_mpd_formats(urljoin(sdn_url, dash_rel_url), video_id, mpd_id='dash', fatal=False))
|
||||
|
||||
hls_rel_url = playlists.get('hls', {}).get('url')
|
||||
if hls_rel_url:
|
||||
formats.extend(self._extract_m3u8_formats(urljoin(sdn_url, hls_rel_url), video_id, ext='mp4', m3u8_id='hls', fatal=False))
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': data['captionTitle'],
|
||||
'title': title,
|
||||
'description': data.get('perex'),
|
||||
'formats': formats,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user