rtl2.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. clean_html,
  8. unified_strdate,
  9. int_or_none,
  10. )
  11. class RTL2IE(InfoExtractor):
  12. """Information Extractor for RTL2"""
  13. _VALID_URL = r'http?://(?P<url>(?P<domain>(www\.)?rtl2\.de)/.*/(?P<video_id>.*))/'
  14. _TESTS = [{
  15. 'url': 'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0',
  16. 'info_dict': {
  17. 'id': 'folge-203-0',
  18. 'ext': 'f4v',
  19. 'title': 'GRIP sucht den Sommerkönig',
  20. 'description' : 'Matthias, Det und Helge treten gegeneinander an.'
  21. },
  22. 'params': {
  23. # rtmp download
  24. 'skip_download': True,
  25. },
  26. },
  27. {
  28. 'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/',
  29. 'info_dict': {
  30. 'id': '21040-anna-erwischt-alex',
  31. 'ext': 'mp4',
  32. 'title': 'Anna erwischt Alex!',
  33. 'description' : 'Anna ist Alex\' Tochter bei Köln 50667.'
  34. },
  35. 'params': {
  36. # rtmp download
  37. 'skip_download': True,
  38. },
  39. },
  40. ]
  41. def _real_extract(self, url):
  42. #Some rtl2 urls have no slash at the end, so append it.
  43. if not url.endswith("/"):
  44. url += '/'
  45. mobj = re.match(self._VALID_URL, url)
  46. video_id = mobj.group('video_id')
  47. webpage = self._download_webpage(url, video_id)
  48. vico_id = self._html_search_regex(r'vico_id\s*:\s*([0-9]+)', webpage, 'vico_id not found');
  49. vivi_id = self._html_search_regex(r'vivi_id\s*:\s*([0-9]+)', webpage, 'vivi_id not found');
  50. info_url = 'http://www.rtl2.de/video/php/get_video.php?vico_id=' + vico_id + '&vivi_id=' + vivi_id
  51. webpage = self._download_webpage(info_url, '')
  52. video_info = self._download_json(info_url, video_id)
  53. download_url = video_info["video"]["streamurl"]
  54. title = video_info["video"]["titel"]
  55. description = video_info["video"]["beschreibung"]
  56. thumbnail = video_info["video"]["image"]
  57. download_url = download_url.replace("\\", "")
  58. stream_url = 'mp4:' + self._html_search_regex(r'ondemand/(.*)', download_url, '%s')
  59. #Debug output
  60. #print('URL: ' + url)
  61. #print('DL URL: ' + download_url)
  62. #print('Stream URL: ' + stream_url)
  63. #print('Title: ' + title)
  64. #print('Description: '+ description)
  65. #print('Video ID: ' + video_id)
  66. formats = [{
  67. 'url' : download_url,
  68. #'app': 'ondemand?_fcs_vhost=cp108781.edgefcs.net',
  69. 'play_path': stream_url,
  70. 'player_url': 'http://www.rtl2.de/flashplayer/vipo_player.swf',
  71. 'page_url': url,
  72. 'flash_version' : "LNX 11,2,202,429",
  73. 'rtmp_conn' : ["S:connect", "O:1", "NS:pageUrl:" + url, "NB:fpad:0", "NN:videoFunction:1", "O:0"],
  74. 'no_resume' : True,
  75. }]
  76. return {
  77. 'id': video_id,
  78. 'title': title,
  79. 'thumbnail' : thumbnail,
  80. 'description' : description,
  81. 'formats': formats,
  82. }