]>
Commit | Line | Data |
---|---|---|
211fd6c6 GJ |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
211fd6c6 | 4 | from .common import InfoExtractor |
d9cf48e8 S |
5 | from ..compat import compat_urllib_parse_urlparse |
6 | from ..utils import ( | |
7 | determine_ext, | |
8 | float_or_none, | |
9 | ) | |
211fd6c6 | 10 | |
d5519808 | 11 | |
211fd6c6 | 12 | class SpiegeltvIE(InfoExtractor): |
939fe70d | 13 | _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/(?:#/)?filme/(?P<id>[\-a-z0-9]+)' |
89c15fe0 | 14 | _TESTS = [{ |
211fd6c6 | 15 | 'url': 'http://www.spiegel.tv/filme/flug-mh370/', |
211fd6c6 GJ |
16 | 'info_dict': { |
17 | 'id': 'flug-mh370', | |
18 | 'ext': 'm4v', | |
19 | 'title': 'Flug MH370', | |
20 | 'description': 'Das Rätsel um die Boeing 777 der Malaysia-Airlines', | |
d5519808 | 21 | 'thumbnail': 're:http://.*\.jpg$', |
db23d8d2 GJ |
22 | }, |
23 | 'params': { | |
d9cf48e8 | 24 | # m3u8 download |
db23d8d2 | 25 | 'skip_download': True, |
211fd6c6 | 26 | } |
939fe70d PH |
27 | }, { |
28 | 'url': 'http://www.spiegel.tv/#/filme/alleskino-die-wahrheit-ueber-maenner/', | |
29 | 'only_matching': True, | |
89c15fe0 | 30 | }] |
211fd6c6 GJ |
31 | |
32 | def _real_extract(self, url): | |
939fe70d PH |
33 | if '/#/' in url: |
34 | url = url.replace('/#/', '/') | |
89c15fe0 | 35 | video_id = self._match_id(url) |
211fd6c6 GJ |
36 | webpage = self._download_webpage(url, video_id) |
37 | title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title') | |
38 | ||
d5519808 PH |
39 | apihost = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com' |
40 | version_json = self._download_json( | |
41 | '%s/version.json' % apihost, video_id, | |
42 | note='Downloading version information') | |
43 | version_name = version_json['version_name'] | |
211fd6c6 | 44 | |
d5519808 PH |
45 | slug_json = self._download_json( |
46 | '%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id), | |
47 | video_id, | |
48 | note='Downloading object information') | |
49 | oid = slug_json['object_id'] | |
211fd6c6 | 50 | |
d5519808 PH |
51 | media_json = self._download_json( |
52 | '%s/%s/restapi/media/%s.json' % (apihost, version_name, oid), | |
53 | video_id, note='Downloading media information') | |
54 | uuid = media_json['uuid'] | |
55 | is_wide = media_json['is_wide'] | |
211fd6c6 | 56 | |
d5519808 | 57 | server_json = self._download_json( |
fafec39d YCH |
58 | 'http://spiegeltv-prod-static.s3.amazonaws.com/projectConfigs/projectConfig.json', |
59 | video_id, note='Downloading server information') | |
d9cf48e8 S |
60 | |
61 | format = '16x9' if is_wide else '4x3' | |
62 | ||
63 | formats = [] | |
64 | for streamingserver in server_json['streamingserver']: | |
65 | endpoint = streamingserver.get('endpoint') | |
66 | if not endpoint: | |
67 | continue | |
68 | play_path = 'mp4:%s_spiegeltv_0500_%s.m4v' % (uuid, format) | |
69 | if endpoint.startswith('rtmp'): | |
70 | formats.append({ | |
71 | 'url': endpoint, | |
72 | 'format_id': 'rtmp', | |
73 | 'app': compat_urllib_parse_urlparse(endpoint).path[1:], | |
74 | 'play_path': play_path, | |
75 | 'player_path': 'http://prod-static.spiegel.tv/frontend-076.swf', | |
76 | 'ext': 'flv', | |
77 | 'rtmp_live': True, | |
78 | }) | |
79 | elif determine_ext(endpoint) == 'm3u8': | |
50f01302 S |
80 | formats.append({ |
81 | 'url': endpoint.replace('[video]', play_path), | |
82 | 'ext': 'm4v', | |
83 | 'format_id': 'hls', # Prefer hls since it allows to workaround georestriction | |
84 | 'protocol': 'm3u8', | |
85 | 'preference': 1, | |
86 | 'http_headers': { | |
36d72810 | 87 | 'Accept-Encoding': 'deflate', # gzip causes trouble on the server side |
50f01302 S |
88 | }, |
89 | }) | |
d9cf48e8 S |
90 | else: |
91 | formats.append({ | |
92 | 'url': endpoint, | |
93 | }) | |
ac21e719 | 94 | self._check_formats(formats, video_id) |
211fd6c6 GJ |
95 | |
96 | thumbnails = [] | |
97 | for image in media_json['images']: | |
d5519808 PH |
98 | thumbnails.append({ |
99 | 'url': image['url'], | |
100 | 'width': image['width'], | |
101 | 'height': image['height'], | |
102 | }) | |
211fd6c6 GJ |
103 | |
104 | description = media_json['subtitle'] | |
89c15fe0 | 105 | duration = float_or_none(media_json.get('duration_in_ms'), scale=1000) |
211fd6c6 | 106 | |
d5519808 | 107 | return { |
211fd6c6 GJ |
108 | 'id': video_id, |
109 | 'title': title, | |
211fd6c6 GJ |
110 | 'description': description, |
111 | 'duration': duration, | |
fafec39d | 112 | 'thumbnails': thumbnails, |
d9cf48e8 | 113 | 'formats': formats, |
5f6a1245 | 114 | } |