1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-12-27 03:23:30 +01:00
yt-dlp/youtube_dl/extractor/golem.py

72 lines
2.1 KiB
Python
Raw Normal View History

2014-09-25 16:25:53 +02:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import (
2014-09-28 10:34:55 +02:00
compat_urlparse,
)
from ..utils import (
2014-09-28 10:34:55 +02:00
determine_ext,
)
2014-09-25 16:25:53 +02: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 10:34:55 +02:00
'duration': 300.44,
2014-09-25 16:25:53 +02:00
'filesize': 65309548,
}
}
_PREFIX = 'http://video.golem.de'
def _real_extract(self, url):
2014-09-28 10:34:55 +02:00
video_id = self._match_id(url)
2014-09-25 16:25:53 +02:00
2014-09-28 10:34:55 +02:00
config = self._download_xml(
'https://video.golem.de/xml/{0}.xml'.format(video_id), video_id)
2014-09-25 16:25:53 +02:00
info = {
2014-09-28 10:34:55 +02:00
'id': video_id,
'title': config.findtext('./title', 'golem'),
'duration': self._float(config.findtext('./playtime'), 'duration'),
2014-09-25 16:25:53 +02:00
}
formats = []
for e in config:
2014-09-28 10:34:55 +02:00
url = e.findtext('./url')
if not url:
continue
formats.append({
'format_id': e.tag,
'url': compat_urlparse.urljoin(self._PREFIX, url),
'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 16:25:53 +02:00
self._sort_formats(formats)
info['formats'] = formats
thumbnails = []
for e in config.findall('.//teaser'):
2014-09-28 10:34:55 +02:00
url = e.findtext('./url')
if not url:
continue
thumbnails.append({
'url': compat_urlparse.urljoin(self._PREFIX, url),
'width': self._int(e.get('width'), 'thumbnail width'),
'height': self._int(e.get('height'), 'thumbnail height'),
})
2014-09-25 16:25:53 +02:00
info['thumbnails'] = thumbnails
return info