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