[Spiegeltv] remove the md5 field to pass Travis test build
[youtube-dl] / 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 class SpiegeltvIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/filme/(?P<id>[\-a-z0-9]+)'
9     _TEST = {
10         'url': 'http://www.spiegel.tv/filme/flug-mh370/',
11         'info_dict': {
12             'id': 'flug-mh370',
13             'ext': 'm4v',
14             'title': 'Flug MH370',
15             'description': 'Das Rätsel um die Boeing 777 der Malaysia-Airlines',
16         },
17         'params': {
18             # rtmp download
19             'skip_download': True,
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         video_id = mobj.group('id')
26
27         webpage = self._download_webpage(url, video_id)
28         title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title')
29
30         apihost           = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com';
31
32         version_json      = self._download_json('%s/version.json' % apihost, None)
33         version_name      = version_json['version_name']
34
35         slug_json         = self._download_json('%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id), None)
36         oid               = slug_json['object_id']
37               
38         media_json        = self._download_json('%s/%s/restapi/media/%s.json' % (apihost, version_name, oid), None)
39         uuid              = media_json['uuid']
40         is_wide           = media_json['is_wide']
41
42         server_json       = self._download_json('http://www.spiegel.tv/streaming_servers/', None)
43         server            = server_json[0]['endpoint']
44
45         thumbnails = []
46         for image in media_json['images']:
47           thumbnails.append({'url': image['url'], 'resolution': str(image['width']) + 'x' + str(image['height']) })
48
49         description = media_json['subtitle']
50         duration = int(round(media_json['duration_in_ms'] / 1000))
51
52         if is_wide:
53           format = '16x9'
54         else:
55           format = '4x3'
56
57         url = server + 'mp4:' + uuid + '_spiegeltv_0500_' + format + '.m4v'
58
59         return_dict = {
60             'id': video_id,
61             'title': title,
62             'url': url,
63             'ext': 'm4v',
64             'description': description,
65             'duration': duration,
66             'thumbnails': thumbnails
67         }
68         return return_dict