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.

79 lines
2.5 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. 'url': 'http://www.tagesschau.de/multimedia/video/video-196.html',
  19. 'md5': '8aaa8bf3ae1ca2652309718c03019128',
  20. 'info_dict': {
  21. 'id': '196',
  22. 'ext': 'mp4',
  23. 'title': 'Ukraine-Konflikt: Klitschko in Kiew als Bürgermeister vereidigt',
  24. 'description': 'md5:f22e4af75821d174fa6c977349682691',
  25. 'thumbnail': 're:http://.*\.jpg',
  26. },
  27. }]
  28. _FORMATS = {
  29. 's': {'width': 256, 'height': 144, 'quality': 1},
  30. 'm': {'width': 512, 'height': 288, 'quality': 2},
  31. 'l': {'width': 960, 'height': 544, 'quality': 3},
  32. }
  33. def _real_extract(self, url):
  34. mobj = re.match(self._VALID_URL, url)
  35. video_id = mobj.group('id')
  36. if video_id.startswith('-'):
  37. display_id = video_id.strip('-')
  38. else:
  39. display_id = video_id
  40. webpage = self._download_webpage(url, display_id)
  41. playerpage = self._download_webpage(
  42. 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id,
  43. display_id, 'Downloading player page')
  44. medias = re.findall(
  45. r'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"',
  46. playerpage)
  47. formats = []
  48. for url, ext, res in medias:
  49. f = {
  50. 'format_id': res + '_' + ext,
  51. 'url': url,
  52. 'ext': ext,
  53. }
  54. f.update(self._FORMATS.get(res, {}))
  55. formats.append(f)
  56. self._sort_formats(formats)
  57. thumbnail = re.findall(r'"(/multimedia/.+?\.jpg)"', playerpage)[-1]
  58. return {
  59. 'id': display_id,
  60. 'title': self._og_search_title(webpage).strip(),
  61. 'thumbnail': 'http://www.tagesschau.de' + thumbnail,
  62. 'formats': formats,
  63. 'description': self._og_search_description(webpage).strip(),
  64. }