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

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class TagesschauIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?tagesschau\.de/multimedia/video/video(?P<id>-?[0-9]+)\.html'
  7. _TESTS = [{
  8. 'url': 'http://www.tagesschau.de/multimedia/video/video1399128.html',
  9. 'md5': 'bcdeac2194fb296d599ce7929dfa4009',
  10. 'info_dict': {
  11. 'id': '1399128',
  12. 'ext': 'mp4',
  13. 'title': 'Harald Range, Generalbundesanwalt, zu den Ermittlungen',
  14. 'description': 'md5:69da3c61275b426426d711bde96463ab',
  15. 'thumbnail': 're:^http:.*\.jpg$',
  16. },
  17. }]
  18. _FORMATS = {
  19. 's': {'width': 256, 'height': 144, 'quality': 1},
  20. 'm': {'width': 512, 'height': 288, 'quality': 2},
  21. 'l': {'width': 960, 'height': 544, 'quality': 3},
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. if video_id.startswith('-'):
  27. display_id = video_id.strip('-')
  28. else:
  29. display_id = video_id
  30. webpage = self._download_webpage(url, display_id)
  31. playerpage = self._download_webpage(
  32. 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id,
  33. display_id, 'Downloading player page')
  34. medias = re.findall(
  35. r'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"',
  36. playerpage)
  37. formats = []
  38. for url, ext, res in medias:
  39. f = {
  40. 'format_id': res + '_' + ext,
  41. 'url': url,
  42. 'ext': ext,
  43. }
  44. f.update(self._FORMATS.get(res, {}))
  45. formats.append(f)
  46. self._sort_formats(formats)
  47. thumbnail = re.findall(r'"(/multimedia/.+?\.jpg)"', playerpage)[-1]
  48. return {
  49. 'id': display_id,
  50. 'title': self._og_search_title(webpage).strip(),
  51. 'thumbnail': 'http://www.tagesschau.de' + thumbnail,
  52. 'formats': formats,
  53. 'description': self._og_search_description(webpage).strip(),
  54. }