4 from .common
import InfoExtractor
14 class StreamCZIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?(?:stream|televizeseznam)\.cz/[^?#]+/(?P<display_id>[^?#]+)-(?P<id>[0-9]+)'
17 'url': 'https://www.televizeseznam.cz/video/lajna/buh-57953890',
18 'md5': '40c41ade1464a390a0b447e333df4239',
24 'description': 'md5:8f5f09b9b7bc67df910486cdd88f7165',
27 'url': 'https://www.stream.cz/tajemno/znicehonic-jim-skrz-strechu-prolitnul-zahadny-predmet-badatele-vse-objasnili-64147267',
28 'md5': '3ee4d0be040e8f4a543e67e509d55e3f',
32 'title': 'Zničehonic jim skrz střechu prolítnul záhadný předmět. Badatelé vše objasnili',
33 'display_id': 'znicehonic-jim-skrz-strechu-prolitnul-zahadny-predmet-badatele-vse-objasnili',
34 'description': 'md5:1dcb5e010eb697dedc5942f76c5b3744',
38 def _extract_formats(self
, spl_url
, video
):
39 for ext
, pref
, streams
in (
40 ('ts', -1, traverse_obj(video
, ('http_stream', 'qualities'))),
41 ('mp4', 1, video
.get('mp4'))):
42 for format_id
, stream
in streams
.items():
43 if not stream
.get('url'):
46 'format_id': f
'{format_id}-{ext}',
48 'source_preference': pref
,
49 'url': urljoin(spl_url
, stream
['url']),
50 'tbr': float_or_none(stream
.get('bandwidth'), scale
=1000),
51 'duration': float_or_none(stream
.get('duration'), scale
=1000),
52 'width': traverse_obj(stream
, ('resolution', 0)),
53 'height': traverse_obj(stream
, ('resolution', 1)) or int_or_none(format_id
.replace('p', '')),
54 **parse_codecs(stream
.get('codec')),
57 def _real_extract(self
, url
):
58 display_id
, video_id
= self
._match
_valid
_url
(url
).groups()
60 data
= self
._download
_json
(
61 'https://www.televizeseznam.cz/api/graphql', video_id
, 'Downloading GraphQL result',
63 'variables': {'urlName': video_id}
,
65 query LoadEpisode($urlName : String){ episode(urlName: $urlName){ ...VideoDetailFragmentOnEpisode } }
66 fragment VideoDetailFragmentOnEpisode on Episode {
76 headers
={'Content-Type': 'application/json;charset=UTF-8'}
79 spl_url
= data
['spl'] + 'spl2,3'
80 metadata
= self
._download
_json
(spl_url
, video_id
, 'Downloading playlist')
81 if 'Location' in metadata
and 'data' not in metadata
:
82 spl_url
= metadata
['Location']
83 metadata
= self
._download
_json
(spl_url
, video_id
, 'Downloading redirected playlist')
84 video
= metadata
['data']
87 for subs
in video
.get('subtitles', {}).values():
88 if not subs
.get('language'):
90 for ext
, sub_url
in subs
.get('urls').items():
91 subtitles
.setdefault(subs
['language'], []).append({
93 'url': urljoin(spl_url
, sub_url
)
96 formats
= list(self
._extract
_formats
(spl_url
, video
))
97 self
._sort
_formats
(formats
)
101 'display_id': display_id
,
102 'title': data
.get('name'),
103 'description': data
.get('perex'),
104 'duration': float_or_none(data
.get('duration')),
105 'view_count': int_or_none(data
.get('views')),
107 'subtitles': subtitles
,