]>
Commit | Line | Data |
---|---|---|
6a5af6ac M |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
6a5af6ac | 4 | from .common import InfoExtractor |
1cc79574 | 5 | from ..compat import ( |
b14f3a4c | 6 | compat_urlparse, |
1cc79574 PH |
7 | ) |
8 | from ..utils import ( | |
b14f3a4c PH |
9 | determine_ext, |
10 | ) | |
6a5af6ac M |
11 | |
12 | ||
13 | class GolemIE(InfoExtractor): | |
14 | _VALID_URL = r'^https?://video\.golem\.de/.+?/(?P<id>.+?)/' | |
15 | _TEST = { | |
16 | 'url': 'http://video.golem.de/handy/14095/iphone-6-und-6-plus-test.html', | |
17 | 'md5': 'c1a2c0a3c863319651c7c992c5ee29bf', | |
18 | 'info_dict': { | |
19 | 'id': '14095', | |
20 | 'format_id': 'high', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'iPhone 6 und 6 Plus - Test', | |
b14f3a4c | 23 | 'duration': 300.44, |
6a5af6ac M |
24 | 'filesize': 65309548, |
25 | } | |
26 | } | |
27 | ||
6a5af6ac M |
28 | _PREFIX = 'http://video.golem.de' |
29 | ||
6a5af6ac | 30 | def _real_extract(self, url): |
b14f3a4c | 31 | video_id = self._match_id(url) |
6a5af6ac | 32 | |
b14f3a4c PH |
33 | config = self._download_xml( |
34 | 'https://video.golem.de/xml/{0}.xml'.format(video_id), video_id) | |
6a5af6ac M |
35 | |
36 | info = { | |
b14f3a4c PH |
37 | 'id': video_id, |
38 | 'title': config.findtext('./title', 'golem'), | |
39 | 'duration': self._float(config.findtext('./playtime'), 'duration'), | |
6a5af6ac M |
40 | } |
41 | ||
42 | formats = [] | |
8157ae39 | 43 | for e in config: |
b14f3a4c PH |
44 | url = e.findtext('./url') |
45 | if not url: | |
b14f3a4c PH |
46 | continue |
47 | ||
48 | formats.append({ | |
49 | 'format_id': e.tag, | |
50 | 'url': compat_urlparse.urljoin(self._PREFIX, url), | |
51 | 'height': self._int(e.get('height'), 'height'), | |
52 | 'width': self._int(e.get('width'), 'width'), | |
53 | 'filesize': self._int(e.findtext('filesize'), 'filesize'), | |
54 | 'ext': determine_ext(e.findtext('./filename')), | |
55 | }) | |
6a5af6ac M |
56 | self._sort_formats(formats) |
57 | info['formats'] = formats | |
58 | ||
59 | thumbnails = [] | |
8157ae39 | 60 | for e in config.findall('.//teaser'): |
b14f3a4c PH |
61 | url = e.findtext('./url') |
62 | if not url: | |
63 | continue | |
64 | thumbnails.append({ | |
65 | 'url': compat_urlparse.urljoin(self._PREFIX, url), | |
66 | 'width': self._int(e.get('width'), 'thumbnail width'), | |
67 | 'height': self._int(e.get('height'), 'thumbnail height'), | |
68 | }) | |
6a5af6ac M |
69 | info['thumbnails'] = thumbnails |
70 | ||
6a5af6ac | 71 | return info |