rtl2.py 2.7 KB

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