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.

72 lines
2.2 KiB

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