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
4.3 KiB

  1. # encoding: utf-8
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  5. class RTLnowIE(InfoExtractor):
  6. """Information Extractor for RTLnow, RTL2now and VOXnow"""
  7. _VALID_URL = r'(?:http://)?(?P<url>(?P<base_url>rtl(?:(?P<is_rtl2>2)|-)now\.rtl(?(is_rtl2)2|)\.de/|(?:www\.)?voxnow\.de/)[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?(?:container_id|film_id)=(?P<video_id>[0-9]+)&player=1(?:&season=[0-9]+)?(?:&.*)?)'
  8. _TESTS = [{
  9. u'url': u'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1',
  10. u'file': u'90419.flv',
  11. u'info_dict': {
  12. u'upload_date': u'20070416',
  13. u'title': u'Ahornallee - Folge 1 - Der Einzug',
  14. u'description': u'Folge 1 - Der Einzug',
  15. },
  16. u'params': {
  17. u'skip_download': True,
  18. },
  19. },
  20. {
  21. u'url': u'http://rtl2now.rtl2.de/aerger-im-revier/episode-15-teil-1.php?film_id=69756&player=1&season=2&index=5',
  22. u'file': u'69756.flv',
  23. u'info_dict': {
  24. u'upload_date': u'20120519',
  25. u'title': u'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit...',
  26. u'description': u'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit u.a.',
  27. u'thumbnail': u'http://autoimg.static-fra.de/rtl2now/219850/1500x1500/image2.jpg',
  28. },
  29. u'params': {
  30. u'skip_download': True,
  31. },
  32. },
  33. {
  34. u'url': u'www.voxnow.de/voxtours/suedafrika-reporter-ii.php?film_id=13883&player=1&season=17',
  35. u'file': u'13883.flv',
  36. u'info_dict': {
  37. u'upload_date': u'20090627',
  38. u'title': u'Voxtours - Südafrika-Reporter II',
  39. u'description': u'Südafrika-Reporter II',
  40. },
  41. u'params': {
  42. u'skip_download': True,
  43. },
  44. }]
  45. def _real_extract(self,url):
  46. mobj = re.match(self._VALID_URL, url)
  47. webpage_url = u'http://' + mobj.group('url')
  48. video_page_url = u'http://' + mobj.group('base_url')
  49. video_id = mobj.group(u'video_id')
  50. webpage = self._download_webpage(webpage_url, video_id)
  51. video_title = self._html_search_regex(r'<title>(?P<title>[^<]+)</title>',
  52. webpage, u'title')
  53. playerdata_url = self._html_search_regex(r'\'playerdata\': \'(?P<playerdata_url>[^\']+)\'',
  54. webpage, u'playerdata_url')
  55. playerdata = self._download_webpage(playerdata_url, video_id)
  56. mobj = re.search(r'<title><!\[CDATA\[(?P<description>.+?)\s+- (?:Sendung )?vom (?P<upload_date_d>[0-9]{2})\.(?P<upload_date_m>[0-9]{2})\.(?:(?P<upload_date_Y>[0-9]{4})|(?P<upload_date_y>[0-9]{2})) [0-9]{2}:[0-9]{2} Uhr\]\]></title>', playerdata)
  57. if mobj:
  58. video_description = mobj.group(u'description')
  59. if mobj.group('upload_date_Y'):
  60. video_upload_date = mobj.group('upload_date_Y')
  61. else:
  62. video_upload_date = u'20' + mobj.group('upload_date_y')
  63. video_upload_date += mobj.group('upload_date_m')+mobj.group('upload_date_d')
  64. else:
  65. video_description = None
  66. video_upload_date = None
  67. self._downloader.report_warning(u'Unable to extract description and upload date')
  68. # Thumbnail: not every video has an thumbnail
  69. mobj = re.search(r'<meta property="og:image" content="(?P<thumbnail>[^"]+)">', webpage)
  70. if mobj:
  71. video_thumbnail = mobj.group(u'thumbnail')
  72. else:
  73. video_thumbnail = None
  74. mobj = re.search(r'<filename [^>]+><!\[CDATA\[(?P<url>rtmpe://(?:[^/]+/){2})(?P<play_path>[^\]]+)\]\]></filename>', playerdata)
  75. if mobj is None:
  76. raise ExtractorError(u'Unable to extract media URL')
  77. video_url = mobj.group(u'url')
  78. video_play_path = u'mp4:' + mobj.group(u'play_path')
  79. video_player_url = video_page_url + u'includes/vodplayer.swf'
  80. return [{
  81. 'id': video_id,
  82. 'url': video_url,
  83. 'play_path': video_play_path,
  84. 'page_url': video_page_url,
  85. 'player_url': video_player_url,
  86. 'ext': 'flv',
  87. 'title': video_title,
  88. 'description': video_description,
  89. 'upload_date': video_upload_date,
  90. 'thumbnail': video_thumbnail,
  91. }]