You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.1 KiB

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