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.

164 lines
6.3 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. clean_html,
  8. unified_strdate,
  9. int_or_none,
  10. )
  11. class RTLnowIE(InfoExtractor):
  12. """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
  13. _VALID_URL = r'''(?x)
  14. (?:https?://)?
  15. (?P<url>
  16. (?P<domain>
  17. rtl-now\.rtl\.de|
  18. rtl2now\.rtl2\.de|
  19. (?:www\.)?voxnow\.de|
  20. (?:www\.)?rtlnitronow\.de|
  21. (?:www\.)?superrtlnow\.de|
  22. (?:www\.)?n-tvnow\.de)
  23. /+[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?
  24. (?:container_id|film_id)=(?P<video_id>[0-9]+)&
  25. player=1(?:&season=[0-9]+)?(?:&.*)?
  26. )'''
  27. _TESTS = [
  28. {
  29. 'url': 'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1',
  30. 'info_dict': {
  31. 'id': '90419',
  32. 'ext': 'flv',
  33. 'title': 'Ahornallee - Folge 1 - Der Einzug',
  34. 'description': 'md5:ce843b6b5901d9a7f7d04d1bbcdb12de',
  35. 'upload_date': '20070416',
  36. 'duration': 1685,
  37. },
  38. 'params': {
  39. 'skip_download': True,
  40. },
  41. 'skip': 'Only works from Germany',
  42. },
  43. {
  44. 'url': 'http://rtl2now.rtl2.de/aerger-im-revier/episode-15-teil-1.php?film_id=69756&player=1&season=2&index=5',
  45. 'info_dict': {
  46. 'id': '69756',
  47. 'ext': 'flv',
  48. 'title': 'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit u.a.',
  49. 'description': 'md5:3fb247005ed21a935ffc82b7dfa70cf0',
  50. 'thumbnail': 'http://autoimg.static-fra.de/rtl2now/219850/1500x1500/image2.jpg',
  51. 'upload_date': '20120519',
  52. 'duration': 1245,
  53. },
  54. 'params': {
  55. 'skip_download': True,
  56. },
  57. 'skip': 'Only works from Germany',
  58. },
  59. {
  60. 'url': 'http://www.voxnow.de/voxtours/suedafrika-reporter-ii.php?film_id=13883&player=1&season=17',
  61. 'info_dict': {
  62. 'id': '13883',
  63. 'ext': 'flv',
  64. 'title': 'Voxtours - Südafrika-Reporter II',
  65. 'description': 'md5:de7f8d56be6fd4fed10f10f57786db00',
  66. 'upload_date': '20090627',
  67. 'duration': 1800,
  68. },
  69. 'params': {
  70. 'skip_download': True,
  71. },
  72. },
  73. {
  74. 'url': 'http://superrtlnow.de/medicopter-117/angst.php?film_id=99205&player=1',
  75. 'info_dict': {
  76. 'id': '99205',
  77. 'ext': 'flv',
  78. 'title': 'Medicopter 117 - Angst!',
  79. 'description': 'md5:895b1df01639b5f61a04fc305a5cb94d',
  80. 'thumbnail': 'http://autoimg.static-fra.de/superrtlnow/287529/1500x1500/image2.jpg',
  81. 'upload_date': '20080928',
  82. 'duration': 2691,
  83. },
  84. 'params': {
  85. 'skip_download': True,
  86. },
  87. },
  88. {
  89. 'url': 'http://www.n-tvnow.de/deluxe-alles-was-spass-macht/thema-ua-luxushotel-fuer-vierbeiner.php?container_id=153819&player=1&season=0',
  90. 'info_dict': {
  91. 'id': '153819',
  92. 'ext': 'flv',
  93. 'title': 'Deluxe - Alles was Spaß macht - Thema u.a.: Luxushotel für Vierbeiner',
  94. 'description': 'md5:c3705e1bb32e1a5b2bcd634fc065c631',
  95. 'thumbnail': 'http://autoimg.static-fra.de/ntvnow/383157/1500x1500/image2.jpg',
  96. 'upload_date': '20140221',
  97. 'duration': 2429,
  98. },
  99. 'skip': 'Only works from Germany',
  100. },
  101. ]
  102. def _real_extract(self, url):
  103. mobj = re.match(self._VALID_URL, url)
  104. video_page_url = 'http://%s/' % mobj.group('domain')
  105. video_id = mobj.group('video_id')
  106. webpage = self._download_webpage('http://' + mobj.group('url'), video_id)
  107. mobj = re.search(r'(?s)<div style="margin-left: 20px; font-size: 13px;">(.*?)<div id="playerteaser">', webpage)
  108. if mobj:
  109. raise ExtractorError(clean_html(mobj.group(1)), expected=True)
  110. title = self._og_search_title(webpage)
  111. description = self._og_search_description(webpage)
  112. thumbnail = self._og_search_thumbnail(webpage, default=None)
  113. upload_date = unified_strdate(self._html_search_meta('uploadDate', webpage, 'upload date'))
  114. mobj = re.search(r'<meta itemprop="duration" content="PT(?P<seconds>\d+)S" />', webpage)
  115. duration = int(mobj.group('seconds')) if mobj else None
  116. playerdata_url = self._html_search_regex(
  117. r"'playerdata': '(?P<playerdata_url>[^']+)'", webpage, 'playerdata_url')
  118. playerdata = self._download_xml(playerdata_url, video_id, 'Downloading player data XML')
  119. videoinfo = playerdata.find('./playlist/videoinfo')
  120. formats = []
  121. for filename in videoinfo.findall('filename'):
  122. mobj = re.search(r'(?P<url>rtmpe://(?:[^/]+/){2})(?P<play_path>.+)', filename.text)
  123. if mobj:
  124. fmt = {
  125. 'url': mobj.group('url'),
  126. 'play_path': 'mp4:' + mobj.group('play_path'),
  127. 'page_url': video_page_url,
  128. 'player_url': video_page_url + 'includes/vodplayer.swf',
  129. }
  130. else:
  131. fmt = {
  132. 'url': filename.text,
  133. }
  134. fmt.update({
  135. 'width': int_or_none(filename.get('width')),
  136. 'height': int_or_none(filename.get('height')),
  137. 'vbr': int_or_none(filename.get('bitrate')),
  138. 'ext': 'flv',
  139. })
  140. formats.append(fmt)
  141. return {
  142. 'id': video_id,
  143. 'title': title,
  144. 'description': description,
  145. 'thumbnail': thumbnail,
  146. 'upload_date': upload_date,
  147. 'duration': duration,
  148. 'formats': formats,
  149. }