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.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import unified_strdate
  5. class DreiSatIE(InfoExtractor):
  6. IE_NAME = '3sat'
  7. _VALID_URL = r'(?:http://)?(?:www\.)?3sat\.de/mediathek/(?:index\.php)?\?(?:(?:mode|display)=[^&]+&)*obj=(?P<id>[0-9]+)$'
  8. _TEST = {
  9. 'url': 'http://www.3sat.de/mediathek/index.php?obj=36983',
  10. 'md5': '9dcfe344732808dbfcc901537973c922',
  11. 'info_dict': {
  12. 'id': '36983',
  13. 'ext': 'mp4',
  14. 'title': 'Kaffeeland Schweiz',
  15. 'description': 'md5:cc4424b18b75ae9948b13929a0814033',
  16. 'uploader': '3sat',
  17. 'upload_date': '20130622'
  18. }
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('id')
  23. details_url = 'http://www.3sat.de/mediathek/xmlservice/web/beitragsDetails?ak=web&id=%s' % video_id
  24. details_doc = self._download_xml(details_url, video_id, 'Downloading video details')
  25. thumbnail_els = details_doc.findall('.//teaserimage')
  26. thumbnails = [{
  27. 'width': int(te.attrib['key'].partition('x')[0]),
  28. 'height': int(te.attrib['key'].partition('x')[2]),
  29. 'url': te.text,
  30. } for te in thumbnail_els]
  31. information_el = details_doc.find('.//information')
  32. video_title = information_el.find('./title').text
  33. video_description = information_el.find('./detail').text
  34. details_el = details_doc.find('.//details')
  35. video_uploader = details_el.find('./channel').text
  36. upload_date = unified_strdate(details_el.find('./airtime').text)
  37. format_els = details_doc.findall('.//formitaet')
  38. formats = [{
  39. 'format_id': fe.attrib['basetype'],
  40. 'width': int(fe.find('./width').text),
  41. 'height': int(fe.find('./height').text),
  42. 'url': fe.find('./url').text,
  43. 'filesize': int(fe.find('./filesize').text),
  44. 'video_bitrate': int(fe.find('./videoBitrate').text),
  45. } for fe in format_els
  46. if not fe.find('./url').text.startswith('http://www.metafilegenerator.de/')]
  47. self._sort_formats(formats)
  48. return {
  49. '_type': 'video',
  50. 'id': video_id,
  51. 'title': video_title,
  52. 'formats': formats,
  53. 'description': video_description,
  54. 'thumbnails': thumbnails,
  55. 'thumbnail': thumbnails[-1]['url'],
  56. 'uploader': video_uploader,
  57. 'upload_date': upload_date,
  58. }