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.

85 lines
2.9 KiB

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