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.

74 lines
2.6 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class SWRMediathekIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?swrmediathek\.de/player\.htm\?show=(?P<videoid>[^?#&]+)'
  8. _TESTS = [{
  9. 'url': 'http://swrmediathek.de/player.htm?show=849790d0-dab8-11e3-a953-0026b975f2e6',
  10. 'info_dict': {
  11. 'id': '849790d0-dab8-11e3-a953-0026b975f2e6',
  12. 'ext': 'flv',
  13. 'title': 'SWR odysso',
  14. 'description': 'md5:2012e31baad36162e97ce9eb3f157b8a',
  15. 'thumbnail': 're:^http:.*\.jpg$',
  16. },
  17. 'params': {
  18. 'skip_download': True, # requires rtmpdump
  19. },
  20. }, {
  21. 'url': 'http://swrmediathek.de/player.htm?show=0e1a8510-ddf2-11e3-9be3-0026b975f2e6',
  22. 'info_dict': {
  23. 'id': '0e1a8510-ddf2-11e3-9be3-0026b975f2e6',
  24. 'ext': 'flv',
  25. 'title': 'Nachtcafé - Alltagsdroge Alkohol - zwischen Sektempfang und Komasaufen',
  26. 'description': 'md5:e0a3adc17e47db2c23aab9ebc36dbee2',
  27. 'thumbnail': 're:http://.*\.jpg',
  28. },
  29. 'params': {
  30. 'skip_download': True, # requires rtmpdump
  31. },
  32. }]
  33. def _real_extract(self, url):
  34. mobj = re.match(self._VALID_URL, url)
  35. video_id = mobj.group('videoid')
  36. webpage = self._download_webpage(url, video_id)
  37. smilurl = 'http://swrmediathek.de/rtmpQuals/%s/clips.smil'
  38. smildoc = self._download_xml(smilurl % video_id, video_id, 'Downloading SMIL page')
  39. baseurl = smildoc.find('.//meta').attrib['base']
  40. formats = []
  41. for video in smildoc.findall('.//video'):
  42. vbr = video.attrib.get('system-bitrate')
  43. if vbr:
  44. vbr = int(vbr) / 1000
  45. formats.append({
  46. 'format_id': video.attrib['height'] + 'p',
  47. 'width': int_or_none(video.attrib['width']),
  48. 'height': int_or_none(video.attrib['height']),
  49. 'vbr': vbr,
  50. 'url': baseurl,
  51. 'play_path': 'mp4:' + video.attrib['src'],
  52. 'ext': 'flv',
  53. })
  54. self._sort_formats(formats)
  55. return {
  56. 'id': video_id,
  57. 'title': self._html_search_meta('title', webpage, 'title', fatal=True),
  58. 'thumbnail': self._search_regex(r'<link rel="image_src".+href="(.+)" />', webpage, 'thumbnail'),
  59. 'formats': formats,
  60. 'description': self._html_search_meta('description', webpage, 'description'),
  61. }