]>
Commit | Line | Data |
---|---|---|
211fd6c6 GJ |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
211fd6c6 | 4 | from .common import InfoExtractor |
89c15fe0 | 5 | from ..utils import float_or_none |
211fd6c6 | 6 | |
d5519808 | 7 | |
211fd6c6 | 8 | class SpiegeltvIE(InfoExtractor): |
939fe70d | 9 | _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/(?:#/)?filme/(?P<id>[\-a-z0-9]+)' |
89c15fe0 | 10 | _TESTS = [{ |
211fd6c6 | 11 | 'url': 'http://www.spiegel.tv/filme/flug-mh370/', |
211fd6c6 GJ |
12 | 'info_dict': { |
13 | 'id': 'flug-mh370', | |
14 | 'ext': 'm4v', | |
15 | 'title': 'Flug MH370', | |
16 | 'description': 'Das Rätsel um die Boeing 777 der Malaysia-Airlines', | |
d5519808 | 17 | 'thumbnail': 're:http://.*\.jpg$', |
db23d8d2 GJ |
18 | }, |
19 | 'params': { | |
20 | # rtmp download | |
21 | 'skip_download': True, | |
211fd6c6 | 22 | } |
939fe70d PH |
23 | }, { |
24 | 'url': 'http://www.spiegel.tv/#/filme/alleskino-die-wahrheit-ueber-maenner/', | |
25 | 'only_matching': True, | |
89c15fe0 | 26 | }] |
211fd6c6 GJ |
27 | |
28 | def _real_extract(self, url): | |
939fe70d PH |
29 | if '/#/' in url: |
30 | url = url.replace('/#/', '/') | |
89c15fe0 | 31 | video_id = self._match_id(url) |
211fd6c6 GJ |
32 | webpage = self._download_webpage(url, video_id) |
33 | title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title') | |
34 | ||
d5519808 PH |
35 | apihost = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com' |
36 | version_json = self._download_json( | |
37 | '%s/version.json' % apihost, video_id, | |
38 | note='Downloading version information') | |
39 | version_name = version_json['version_name'] | |
211fd6c6 | 40 | |
d5519808 PH |
41 | slug_json = self._download_json( |
42 | '%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id), | |
43 | video_id, | |
44 | note='Downloading object information') | |
45 | oid = slug_json['object_id'] | |
211fd6c6 | 46 | |
d5519808 PH |
47 | media_json = self._download_json( |
48 | '%s/%s/restapi/media/%s.json' % (apihost, version_name, oid), | |
49 | video_id, note='Downloading media information') | |
50 | uuid = media_json['uuid'] | |
51 | is_wide = media_json['is_wide'] | |
211fd6c6 | 52 | |
d5519808 PH |
53 | server_json = self._download_json( |
54 | 'http://www.spiegel.tv/streaming_servers/', video_id, | |
55 | note='Downloading server information') | |
56 | server = server_json[0]['endpoint'] | |
211fd6c6 GJ |
57 | |
58 | thumbnails = [] | |
59 | for image in media_json['images']: | |
d5519808 PH |
60 | thumbnails.append({ |
61 | 'url': image['url'], | |
62 | 'width': image['width'], | |
63 | 'height': image['height'], | |
64 | }) | |
211fd6c6 GJ |
65 | |
66 | description = media_json['subtitle'] | |
89c15fe0 PH |
67 | duration = float_or_none(media_json.get('duration_in_ms'), scale=1000) |
68 | format = '16x9' if is_wide else '4x3' | |
211fd6c6 GJ |
69 | |
70 | url = server + 'mp4:' + uuid + '_spiegeltv_0500_' + format + '.m4v' | |
71 | ||
d5519808 | 72 | return { |
211fd6c6 GJ |
73 | 'id': video_id, |
74 | 'title': title, | |
75 | 'url': url, | |
76 | 'ext': 'm4v', | |
77 | 'description': description, | |
78 | 'duration': duration, | |
79 | 'thumbnails': thumbnails | |
d5519808 | 80 | } |