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.

71 lines
2.1 KiB

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