2024-06-11 17:09:58 -06:00
|
|
|
import urllib.parse
|
|
|
|
|
2014-09-25 08:25:53 -06:00
|
|
|
from .common import InfoExtractor
|
2014-12-13 04:24:42 -07:00
|
|
|
from ..utils import (
|
2014-09-28 02:34:55 -06:00
|
|
|
determine_ext,
|
|
|
|
)
|
2014-09-25 08:25:53 -06:00
|
|
|
|
|
|
|
|
|
|
|
class GolemIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'^https?://video\.golem\.de/.+?/(?P<id>.+?)/'
|
|
|
|
_TEST = {
|
|
|
|
'url': 'http://video.golem.de/handy/14095/iphone-6-und-6-plus-test.html',
|
|
|
|
'md5': 'c1a2c0a3c863319651c7c992c5ee29bf',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '14095',
|
|
|
|
'format_id': 'high',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'iPhone 6 und 6 Plus - Test',
|
2014-09-28 02:34:55 -06:00
|
|
|
'duration': 300.44,
|
2014-09-25 08:25:53 -06:00
|
|
|
'filesize': 65309548,
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2014-09-25 08:25:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
_PREFIX = 'http://video.golem.de'
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-09-28 02:34:55 -06:00
|
|
|
video_id = self._match_id(url)
|
2014-09-25 08:25:53 -06:00
|
|
|
|
2014-09-28 02:34:55 -06:00
|
|
|
config = self._download_xml(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'https://video.golem.de/xml/{video_id}.xml', video_id)
|
2014-09-25 08:25:53 -06:00
|
|
|
|
|
|
|
info = {
|
2014-09-28 02:34:55 -06:00
|
|
|
'id': video_id,
|
|
|
|
'title': config.findtext('./title', 'golem'),
|
|
|
|
'duration': self._float(config.findtext('./playtime'), 'duration'),
|
2014-09-25 08:25:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
formats = []
|
2014-09-28 21:48:56 -06:00
|
|
|
for e in config:
|
2014-09-28 02:34:55 -06:00
|
|
|
url = e.findtext('./url')
|
|
|
|
if not url:
|
|
|
|
continue
|
|
|
|
|
|
|
|
formats.append({
|
2024-06-11 17:09:58 -06:00
|
|
|
'format_id': str(e.tag),
|
|
|
|
'url': urllib.parse.urljoin(self._PREFIX, url),
|
2014-09-28 02:34:55 -06:00
|
|
|
'height': self._int(e.get('height'), 'height'),
|
|
|
|
'width': self._int(e.get('width'), 'width'),
|
|
|
|
'filesize': self._int(e.findtext('filesize'), 'filesize'),
|
|
|
|
'ext': determine_ext(e.findtext('./filename')),
|
|
|
|
})
|
2014-09-25 08:25:53 -06:00
|
|
|
info['formats'] = formats
|
|
|
|
|
|
|
|
thumbnails = []
|
2014-09-28 21:48:56 -06:00
|
|
|
for e in config.findall('.//teaser'):
|
2014-09-28 02:34:55 -06:00
|
|
|
url = e.findtext('./url')
|
|
|
|
if not url:
|
|
|
|
continue
|
|
|
|
thumbnails.append({
|
2024-06-11 17:09:58 -06:00
|
|
|
'url': urllib.parse.urljoin(self._PREFIX, url),
|
2014-09-28 02:34:55 -06:00
|
|
|
'width': self._int(e.get('width'), 'thumbnail width'),
|
|
|
|
'height': self._int(e.get('height'), 'thumbnail height'),
|
|
|
|
})
|
2014-09-25 08:25:53 -06:00
|
|
|
info['thumbnails'] = thumbnails
|
|
|
|
|
|
|
|
return info
|