]>
Commit | Line | Data |
---|---|---|
5f627b44 PK |
1 | # coding: utf-8 |
2 | ||
3 | from __future__ import unicode_literals | |
4 | ||
5f627b44 PK |
5 | from .common import InfoExtractor |
6 | from ..utils import ( | |
b9465395 PH |
7 | js_to_json, |
8 | unescapeHTML | |
5f627b44 PK |
9 | ) |
10 | ||
11 | ||
12 | class DVTVIE(InfoExtractor): | |
b9465395 PH |
13 | IE_NAME = 'dvtv' |
14 | IE_DESC = 'http://video.aktualne.cz/dvtv/' | |
15 | ||
16 | _VALID_URL = r'http://video\.aktualne\.cz/dvtv/(?P<id>[a-z0-9-]+/r~[0-9a-f]{32})/?' | |
17 | ||
18 | _TESTS = [{ | |
19 | 'url': 'http://video.aktualne.cz/dvtv/vondra-o-ceskem-stoleti-pri-pohledu-na-havla-mi-bylo-trapne/r~e5efe9ca855511e4833a0025900fea04/', | |
20 | 'md5': '75800f964fa0f82939a2914563301f72', | |
21 | 'info_dict': { | |
22 | 'id': 'e5efe9ca855511e4833a0025900fea04', | |
23 | 'ext': 'webm', | |
24 | 'title': 'Vondra o Českém století: Při pohledu na Havla mi bylo trapně' | |
25 | } | |
26 | }, { | |
27 | 'url': 'http://video.aktualne.cz/dvtv/stropnicky-policie-vrbetice-preventivne-nekontrolovala/r~82ed4322849211e4a10c0025900fea04/', | |
28 | 'md5': '6388f1941b48537dbd28791f712af8bf', | |
29 | 'info_dict': { | |
30 | 'id': '82ed4322849211e4a10c0025900fea04', | |
31 | 'ext': 'mp4', | |
32 | 'title': 'Stropnický: Policie Vrbětice preventivně nekontrolovala' | |
33 | } | |
34 | }] | |
35 | ||
36 | def _real_extract(self, url): | |
37 | video_id = self._match_id(url) | |
38 | webpage = self._download_webpage(url, video_id) | |
39 | ||
40 | code = self._search_regex( | |
41 | r'(?s)embedData[0-9a-f]{32}\[\'asset\'\] = (\{.+?\});', | |
42 | webpage, 'video JSON') | |
43 | payload = self._parse_json(code, video_id, transform_source=js_to_json) | |
44 | formats = [] | |
45 | for source in payload['sources']: | |
46 | ext = source['type'][6:] | |
47 | formats.append({ | |
48 | 'url': source['file'], | |
49 | 'ext': ext, | |
50 | 'format': '%s %s' % (ext, source['label']), | |
51 | 'format_id': '%s-%s' % (ext, source['label']), | |
52 | 'height': int(source['label'].rstrip('p')), | |
53 | 'fps': 25, | |
54 | }) | |
55 | self._sort_formats(formats) | |
56 | ||
57 | return { | |
58 | 'id': video_id[-32:], | |
59 | 'display_id': video_id[:-35], | |
60 | 'title': unescapeHTML(payload['title']), | |
61 | 'thumbnail': 'http:%s' % payload['image'], | |
62 | 'formats': formats | |
63 | } |