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.

100 lines
3.5 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. ExtractorError,
  8. clean_html,
  9. unified_strdate,
  10. int_or_none,
  11. )
  12. class RTL2IE(InfoExtractor):
  13. """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
  14. _VALID_URL = r'http?://(?P<url>(?P<domain>(www\.)?rtl2\.de)/.*/(?P<video_id>.*))'
  15. _TESTS = [{
  16. 'url': 'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0',
  17. 'info_dict': {
  18. 'id': 'folge-203-0',
  19. 'ext': 'f4v',
  20. 'title': 'GRIP sucht den Sommerk\xf6nig',
  21. 'description' : 'Matthias, Det und Helge treten gegeneinander an.'
  22. },
  23. 'params': {
  24. # rtmp download
  25. #'skip_download': True,
  26. },
  27. },
  28. {
  29. 'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/',
  30. 'info_dict': {
  31. 'id': '21040-anna-erwischt-alex',
  32. 'ext': 'f4v',
  33. 'title': 'GRIP sucht den Sommerk\xf6nig',
  34. 'description' : 'Matthias, Det und Helge treten gegeneinander an.'
  35. },
  36. 'params': {
  37. # rtmp download
  38. #'skip_download': True,
  39. },
  40. },
  41. ]
  42. def _real_extract(self, url):
  43. mobj = re.match(self._VALID_URL, url)
  44. video_page_url = 'http://%s/' % mobj.group('domain')
  45. video_id = mobj.group('video_id')
  46. webpage = self._download_webpage('http://' + mobj.group('url'), video_id)
  47. vico_id = self._html_search_regex(r'vico_id\s*:\s*([0-9]+)', webpage, '%s');
  48. vivi_id = self._html_search_regex(r'vivi_id\s*:\s*([0-9]+)', webpage, '%s');
  49. info_url = 'http://www.rtl2.de/video/php/get_video.php?vico_id=' + vico_id + '&vivi_id=' + vivi_id
  50. webpage = self._download_webpage(info_url, '')
  51. video_info = json.loads(webpage)
  52. download_url = video_info["video"]["streamurl"] # self._html_search_regex(r'streamurl\":\"(.*?)\"', webpage, '%s');
  53. title = video_info["video"]["titel"] # self._html_search_regex(r'titel\":\"(.*?)\"', webpage, '%s');
  54. description = video_info["video"]["beschreibung"] # self._html_search_regex(r'beschreibung\":\"(.*?)\"', webpage, '%s');
  55. #ext = self._html_search_regex(r'streamurl\":\".*?(\..{2,4})\"', webpage, '%s');
  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. #print(download_url)
  60. #print(stream_url)
  61. #print(title)
  62. #print(description)
  63. #print(video_id)
  64. formats = []
  65. fmt = {
  66. 'url' : download_url,
  67. #'app': 'ondemand?_fcs_vhost=cp108781.edgefcs.net',
  68. 'play_path': stream_url,
  69. 'player_url': 'http://www.rtl2.de/flashplayer/vipo_player.swf',
  70. 'page_url': url,
  71. 'flash_version' : "LNX 11,2,202,429",
  72. 'rtmp_conn' : ["S:connect", "O:1", "NS:pageUrl:" + url, "NB:fpad:0", "NN:videoFunction:1", "O:0"],
  73. 'no_resume' : 1,
  74. }
  75. formats.append(fmt)
  76. return {
  77. 'id': video_id,
  78. 'title': title,
  79. 'thumbnail' : thumbnail,
  80. 'description' : description,
  81. 'formats': formats,
  82. }