]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spiegeltv.py
debian/watch: Make use of the signing key from upstream.
[youtubedl] / youtube_dl / extractor / spiegeltv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5 from .common import InfoExtractor
6
7
8 class SpiegeltvIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/filme/(?P<id>[\-a-z0-9]+)'
10 _TEST = {
11 'url': 'http://www.spiegel.tv/filme/flug-mh370/',
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',
17 'thumbnail': 're:http://.*\.jpg$',
18 },
19 'params': {
20 # rtmp download
21 'skip_download': True,
22 }
23 }
24
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
27 video_id = mobj.group('id')
28
29 webpage = self._download_webpage(url, video_id)
30 title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title')
31
32 apihost = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com'
33 version_json = self._download_json(
34 '%s/version.json' % apihost, video_id,
35 note='Downloading version information')
36 version_name = version_json['version_name']
37
38 slug_json = self._download_json(
39 '%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id),
40 video_id,
41 note='Downloading object information')
42 oid = slug_json['object_id']
43
44 media_json = self._download_json(
45 '%s/%s/restapi/media/%s.json' % (apihost, version_name, oid),
46 video_id, note='Downloading media information')
47 uuid = media_json['uuid']
48 is_wide = media_json['is_wide']
49
50 server_json = self._download_json(
51 'http://www.spiegel.tv/streaming_servers/', video_id,
52 note='Downloading server information')
53 server = server_json[0]['endpoint']
54
55 thumbnails = []
56 for image in media_json['images']:
57 thumbnails.append({
58 'url': image['url'],
59 'width': image['width'],
60 'height': image['height'],
61 })
62
63 description = media_json['subtitle']
64 duration = media_json['duration_in_ms'] / 1000.
65
66 if is_wide:
67 format = '16x9'
68 else:
69 format = '4x3'
70
71 url = server + 'mp4:' + uuid + '_spiegeltv_0500_' + format + '.m4v'
72
73 return {
74 'id': video_id,
75 'title': title,
76 'url': url,
77 'ext': 'm4v',
78 'description': description,
79 'duration': duration,
80 'thumbnails': thumbnails
81 }