]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/streamcz.py
1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
14 class StreamCZIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?stream\.cz/.+/(?P<videoid>.+)'
18 'url': 'http://www.stream.cz/peklonataliri/765767-ecka-pro-deti',
19 'md5': '6d3ca61a8d0633c9c542b92fcb936b0c',
23 'title': 'Peklo na talíři: Éčka pro děti',
24 'description': 'md5:49ace0df986e95e331d0fe239d421519',
25 'thumbnail': 'http://im.stream.cz/episode/52961d7e19d423f8f06f0100',
29 'url': 'http://www.stream.cz/blanik/10002447-tri-roky-pro-mazanka',
30 'md5': '246272e753e26bbace7fcd9deca0650c',
34 'title': 'Kancelář Blaník: Tři roky pro Mazánka',
35 'description': 'md5:9177695a8b756a0a8ab160de4043b392',
36 'thumbnail': 'http://im.stream.cz/episode/537f838c50c11f8d21320000',
41 def _real_extract(self
, url
):
42 mobj
= re
.match(self
._VALID
_URL
, url
)
43 video_id
= mobj
.group('videoid')
45 webpage
= self
._download
_webpage
(url
, video_id
)
47 data
= self
._html
_search
_regex
(r
'Stream\.Data\.Episode\((.+?)\);', webpage
, 'stream data')
49 jsonData
= json
.loads(data
)
52 for video
in jsonData
['instances']:
53 for video_format
in video
['instances']:
54 format_id
= video_format
['quality']
56 if format_id
== '240p':
58 elif format_id
== '360p':
60 elif format_id
== '480p':
62 elif format_id
== '720p':
66 'format_id': '%s-%s' % (video_format
['type'].split('/')[1], format_id
),
67 'url': video_format
['source'],
71 self
._sort
_formats
(formats
)
74 'id': compat_str(jsonData
['episode_id']),
75 'title': self
._og
_search
_title
(webpage
),
76 'thumbnail': jsonData
['episode_image_original_url'].replace('//', 'http://'),
78 'description': self
._og
_search
_description
(webpage
),
79 'duration': int_or_none(jsonData
['duration']),
80 'view_count': int_or_none(jsonData
['stats_total']),