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.

72 lines
2.6 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class RTL2IE(InfoExtractor):
  5. _VALID_URL = r'http?://(?:www\.)?rtl2\.de/[^?#]*?/(?P<id>[^?#/]*?)(?:$|/(?:$|[?#]))'
  6. _TESTS = [{
  7. 'url': 'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0',
  8. 'md5': 'bfcc179030535b08dc2b36b469b5adc7',
  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. }, {
  16. 'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/',
  17. 'md5': 'ffcd517d2805b57ce11a58a2980c2b02',
  18. 'info_dict': {
  19. 'id': '21040-anna-erwischt-alex',
  20. 'ext': 'mp4',
  21. 'title': 'Anna erwischt Alex!',
  22. 'description': 'Anna ist Alex\' Tochter bei Köln 50667.'
  23. },
  24. }]
  25. def _real_extract(self, url):
  26. # Some rtl2 urls have no slash at the end, so append it.
  27. if not url.endswith('/'):
  28. url += '/'
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(url, video_id)
  31. vico_id = self._html_search_regex(
  32. r'vico_id\s*:\s*([0-9]+)', webpage, 'vico_id')
  33. vivi_id = self._html_search_regex(
  34. r'vivi_id\s*:\s*([0-9]+)', webpage, 'vivi_id')
  35. info_url = 'http://www.rtl2.de/video/php/get_video.php?vico_id=' + vico_id + '&vivi_id=' + vivi_id
  36. webpage = self._download_webpage(info_url, '')
  37. info = self._download_json(info_url, video_id)
  38. video_info = info['video']
  39. title = video_info['titel']
  40. description = video_info.get('beschreibung')
  41. thumbnail = video_info.get('image')
  42. download_url = video_info['streamurl']
  43. download_url = download_url.replace('\\', '')
  44. stream_url = 'mp4:' + self._html_search_regex(r'ondemand/(.*)', download_url, 'stream URL')
  45. rtmp_conn = ["S:connect", "O:1", "NS:pageUrl:" + url, "NB:fpad:0", "NN:videoFunction:1", "O:0"]
  46. formats = [{
  47. 'url': download_url,
  48. 'play_path': stream_url,
  49. 'player_url': 'http://www.rtl2.de/flashplayer/vipo_player.swf',
  50. 'page_url': url,
  51. 'flash_version': 'LNX 11,2,202,429',
  52. 'rtmp_conn': rtmp_conn,
  53. 'no_resume': True,
  54. }]
  55. self._sort_formats(formats)
  56. return {
  57. 'id': video_id,
  58. 'title': title,
  59. 'thumbnail': thumbnail,
  60. 'description': description,
  61. 'formats': formats,
  62. }