]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/streamcz.py
d3d2b7eb7a6fa9db4008365e62e046b83490b064
1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
14 def _get_api_key(api_path
):
15 if api_path
.endswith('?'):
16 api_path
= api_path
[:-1]
18 api_key
= 'fb5f58a820353bd7095de526253c14fd'
19 a
= '{0:}{1:}{2:}'.format(api_key
, api_path
, int(round(time
.time() / 24 / 3600)))
20 return hashlib
.md5(a
.encode('ascii')).hexdigest()
23 class StreamCZIE(InfoExtractor
):
24 _VALID_URL
= r
'https?://(?:www\.)?stream\.cz/.+/(?P<id>[0-9]+)'
25 _API_URL
= 'http://www.stream.cz/API'
28 'url': 'http://www.stream.cz/peklonataliri/765767-ecka-pro-deti',
29 'md5': '6d3ca61a8d0633c9c542b92fcb936b0c',
33 'title': 'Peklo na talíři: Éčka pro děti',
34 'description': 'Taška s grónskou pomazánkou a další pekelnosti ZDE',
35 'thumbnail': 're:^http://im.stream.cz/episode/52961d7e19d423f8f06f0100',
39 'url': 'http://www.stream.cz/blanik/10002447-tri-roky-pro-mazanka',
40 'md5': 'e54a254fb8b871968fd8403255f28589',
44 'title': 'Kancelář Blaník: Tři roky pro Mazánka',
45 'description': 'md5:3862a00ba7bf0b3e44806b544032c859',
46 'thumbnail': 're:^http://im.stream.cz/episode/537f838c50c11f8d21320000',
51 def _real_extract(self
, url
):
52 video_id
= self
._match
_id
(url
)
53 api_path
= '/episode/%s' % video_id
55 req
= sanitized_Request(self
._API
_URL
+ api_path
)
56 req
.add_header('Api-Password', _get_api_key(api_path
))
57 data
= self
._download
_json
(req
, video_id
)
60 for quality
, video
in enumerate(data
['video_qualities']):
61 for f
in video
['formats']:
62 typ
= f
['type'].partition('/')[2]
63 qlabel
= video
.get('quality_label')
65 'format_note': '%s-%s' % (qlabel
, typ
) if qlabel
else typ
,
66 'format_id': '%s-%s' % (typ
, f
['quality']),
68 'height': int_or_none(f
['quality'].rstrip('p')),
71 self
._sort
_formats
(formats
)
73 image
= data
.get('image')
75 thumbnail
= self
._proto
_relative
_url
(
76 image
.replace('{width}', '1240').replace('{height}', '697'),
82 stream
= data
.get('_embedded', {}).get('stream:show', {}).get('name')
84 title
= '%s: %s' % (stream
, data
['name'])
91 'thumbnail': thumbnail
,
93 'description': data
.get('web_site_text'),
94 'duration': int_or_none(data
.get('duration')),
95 'view_count': int_or_none(data
.get('views')),