]>
Commit | Line | Data |
---|---|---|
0793a7b3 | 1 | # -*- coding: utf-8 -*- |
2 | from __future__ import unicode_literals | |
3 | ||
0793a7b3 | 4 | from .common import InfoExtractor |
418424e5 S |
5 | from ..utils import ( |
6 | int_or_none, | |
418424e5 | 7 | ) |
0793a7b3 | 8 | |
9 | ||
10 | class StreamCZIE(InfoExtractor): | |
20e35880 | 11 | _VALID_URL = r'https?://(?:www\.)?stream\.cz/.+/(?P<id>[0-9]+)' |
0793a7b3 | 12 | |
865dbd4a | 13 | _TESTS = [{ |
0793a7b3 | 14 | 'url': 'http://www.stream.cz/peklonataliri/765767-ecka-pro-deti', |
15 | 'md5': '6d3ca61a8d0633c9c542b92fcb936b0c', | |
16 | 'info_dict': { | |
17 | 'id': '765767', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Peklo na talíři: Éčka pro děti', | |
20e35880 PH |
20 | 'description': 'Taška s grónskou pomazánkou a další pekelnosti ZDE', |
21 | 'thumbnail': 're:^http://im.stream.cz/episode/52961d7e19d423f8f06f0100', | |
fa78f133 | 22 | 'duration': 256, |
0793a7b3 | 23 | }, |
865dbd4a | 24 | }, { |
c70df210 | 25 | 'url': 'http://www.stream.cz/blanik/10002447-tri-roky-pro-mazanka', |
20e35880 | 26 | 'md5': 'e54a254fb8b871968fd8403255f28589', |
865dbd4a | 27 | 'info_dict': { |
28 | 'id': '10002447', | |
29 | 'ext': 'mp4', | |
30 | 'title': 'Kancelář Blaník: Tři roky pro Mazánka', | |
20e35880 PH |
31 | 'description': 'md5:3862a00ba7bf0b3e44806b544032c859', |
32 | 'thumbnail': 're:^http://im.stream.cz/episode/537f838c50c11f8d21320000', | |
865dbd4a | 33 | 'duration': 368, |
34 | }, | |
35 | }] | |
0793a7b3 | 36 | |
37 | def _real_extract(self, url): | |
20e35880 PH |
38 | video_id = self._match_id(url) |
39 | data = self._download_json( | |
40 | 'http://www.stream.cz/API/episode/%s' % video_id, video_id) | |
0793a7b3 | 41 | |
42 | formats = [] | |
20e35880 PH |
43 | for quality, video in enumerate(data['video_qualities']): |
44 | for f in video['formats']: | |
45 | typ = f['type'].partition('/')[2] | |
46 | qlabel = video.get('quality_label') | |
fa78f133 | 47 | formats.append({ |
20e35880 PH |
48 | 'format_note': '%s-%s' % (qlabel, typ) if qlabel else typ, |
49 | 'format_id': '%s-%s' % (typ, f['quality']), | |
50 | 'url': f['source'], | |
51 | 'height': int_or_none(f['quality'].rstrip('p')), | |
fa78f133 S |
52 | 'quality': quality, |
53 | }) | |
0793a7b3 | 54 | self._sort_formats(formats) |
55 | ||
20e35880 PH |
56 | image = data.get('image') |
57 | if image: | |
58 | thumbnail = self._proto_relative_url( | |
59 | image.replace('{width}', '1240').replace('{height}', '697'), | |
60 | scheme='http:', | |
61 | ) | |
62 | else: | |
63 | thumbnail = None | |
64 | ||
65 | stream = data.get('_embedded', {}).get('stream:show', {}).get('name') | |
66 | if stream: | |
67 | title = '%s: %s' % (stream, data['name']) | |
68 | else: | |
69 | title = data['name'] | |
70 | ||
0793a7b3 | 71 | return { |
20e35880 PH |
72 | 'id': video_id, |
73 | 'title': title, | |
74 | 'thumbnail': thumbnail, | |
0793a7b3 | 75 | 'formats': formats, |
20e35880 PH |
76 | 'description': data.get('web_site_text'), |
77 | 'duration': int_or_none(data.get('duration')), | |
78 | 'view_count': int_or_none(data.get('views')), | |
0793a7b3 | 79 | } |