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

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