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