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.2 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.findall('./*[url]'):
  34. url = e.findtext('./url')
  35. if not url:
  36. self._downloader.report_warning(
  37. "{0}: url: empty, skipping".format(e.tag))
  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[url]'):
  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