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.

156 lines
6.4 KiB

  1. # encoding: utf-8
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. clean_html,
  6. ExtractorError,
  7. )
  8. class RTLnowIE(InfoExtractor):
  9. """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
  10. _VALID_URL = r'(?:http://)?(?P<url>(?P<base_url>rtl-now\.rtl\.de/|rtl2now\.rtl2\.de/|(?:www\.)?voxnow\.de/|(?:www\.)?rtlnitronow\.de/|(?:www\.)?superrtlnow\.de/|(?:www\.)?n-tvnow\.de/)[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?(?:container_id|film_id)=(?P<video_id>[0-9]+)&player=1(?:&season=[0-9]+)?(?:&.*)?)'
  11. _TESTS = [{
  12. u'url': u'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1',
  13. u'file': u'90419.flv',
  14. u'info_dict': {
  15. u'upload_date': u'20070416',
  16. u'title': u'Ahornallee - Folge 1 - Der Einzug',
  17. u'description': u'Folge 1 - Der Einzug',
  18. },
  19. u'params': {
  20. u'skip_download': True,
  21. },
  22. u'skip': u'Only works from Germany',
  23. },
  24. {
  25. u'url': u'http://rtl2now.rtl2.de/aerger-im-revier/episode-15-teil-1.php?film_id=69756&player=1&season=2&index=5',
  26. u'file': u'69756.flv',
  27. u'info_dict': {
  28. u'upload_date': u'20120519',
  29. u'title': u'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit...',
  30. u'description': u'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit u.a.',
  31. u'thumbnail': u'http://autoimg.static-fra.de/rtl2now/219850/1500x1500/image2.jpg',
  32. },
  33. u'params': {
  34. u'skip_download': True,
  35. },
  36. u'skip': u'Only works from Germany',
  37. },
  38. {
  39. u'url': u'www.voxnow.de/voxtours/suedafrika-reporter-ii.php?film_id=13883&player=1&season=17',
  40. u'file': u'13883.flv',
  41. u'info_dict': {
  42. u'upload_date': u'20090627',
  43. u'title': u'Voxtours - Südafrika-Reporter II',
  44. u'description': u'Südafrika-Reporter II',
  45. },
  46. u'params': {
  47. u'skip_download': True,
  48. },
  49. },
  50. {
  51. u'url': u'http://superrtlnow.de/medicopter-117/angst.php?film_id=99205&player=1',
  52. u'file': u'99205.flv',
  53. u'info_dict': {
  54. u'upload_date': u'20080928',
  55. u'title': u'Medicopter 117 - Angst!',
  56. u'description': u'Angst!',
  57. u'thumbnail': u'http://autoimg.static-fra.de/superrtlnow/287529/1500x1500/image2.jpg'
  58. },
  59. u'params': {
  60. u'skip_download': True,
  61. },
  62. },
  63. {
  64. u'url': u'http://www.rtlnitronow.de/recht-ordnung/lebensmittelkontrolle-erlangenordnungsamt-berlin.php?film_id=127367&player=1&season=1',
  65. u'file': u'127367.flv',
  66. u'info_dict': {
  67. u'upload_date': u'20130926',
  68. u'title': u'Recht & Ordnung - Lebensmittelkontrolle Erlangen/Ordnungsamt...',
  69. u'description': u'Lebensmittelkontrolle Erlangen/Ordnungsamt Berlin',
  70. u'thumbnail': u'http://autoimg.static-fra.de/nitronow/344787/1500x1500/image2.jpg',
  71. },
  72. u'params': {
  73. u'skip_download': True,
  74. },
  75. },
  76. {
  77. u'url': u'http://www.n-tvnow.de/top-gear/episode-1-2013-01-01-00-00-00.php?film_id=124903&player=1&season=10',
  78. u'file': u'124903.flv',
  79. u'info_dict': {
  80. u'upload_date': u'20130101',
  81. u'title': u'Top Gear vom 01.01.2013',
  82. u'description': u'Episode 1',
  83. },
  84. u'params': {
  85. u'skip_download': True,
  86. },
  87. u'skip': u'Only works from Germany',
  88. }]
  89. def _real_extract(self,url):
  90. mobj = re.match(self._VALID_URL, url)
  91. webpage_url = u'http://' + mobj.group('url')
  92. video_page_url = u'http://' + mobj.group('base_url')
  93. video_id = mobj.group(u'video_id')
  94. webpage = self._download_webpage(webpage_url, video_id)
  95. note_m = re.search(r'''(?sx)
  96. <div[ ]style="margin-left:[ ]20px;[ ]font-size:[ ]13px;">(.*?)
  97. <div[ ]id="playerteaser">''', webpage)
  98. if note_m:
  99. msg = clean_html(note_m.group(1))
  100. raise ExtractorError(msg)
  101. video_title = self._html_search_regex(r'<title>(?P<title>[^<]+?)( \| [^<]*)?</title>',
  102. webpage, u'title')
  103. playerdata_url = self._html_search_regex(r'\'playerdata\': \'(?P<playerdata_url>[^\']+)\'',
  104. webpage, u'playerdata_url')
  105. playerdata = self._download_webpage(playerdata_url, video_id)
  106. 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)
  107. if mobj:
  108. video_description = mobj.group(u'description')
  109. if mobj.group('upload_date_Y'):
  110. video_upload_date = mobj.group('upload_date_Y')
  111. elif mobj.group('upload_date_y'):
  112. video_upload_date = u'20' + mobj.group('upload_date_y')
  113. else:
  114. video_upload_date = None
  115. if video_upload_date:
  116. video_upload_date += mobj.group('upload_date_m')+mobj.group('upload_date_d')
  117. else:
  118. video_description = None
  119. video_upload_date = None
  120. self._downloader.report_warning(u'Unable to extract description and upload date')
  121. # Thumbnail: not every video has an thumbnail
  122. mobj = re.search(r'<meta property="og:image" content="(?P<thumbnail>[^"]+)">', webpage)
  123. if mobj:
  124. video_thumbnail = mobj.group(u'thumbnail')
  125. else:
  126. video_thumbnail = None
  127. mobj = re.search(r'<filename [^>]+><!\[CDATA\[(?P<url>rtmpe://(?:[^/]+/){2})(?P<play_path>[^\]]+)\]\]></filename>', playerdata)
  128. if mobj is None:
  129. raise ExtractorError(u'Unable to extract media URL')
  130. video_url = mobj.group(u'url')
  131. video_play_path = u'mp4:' + mobj.group(u'play_path')
  132. video_player_url = video_page_url + u'includes/vodplayer.swf'
  133. return [{
  134. 'id': video_id,
  135. 'url': video_url,
  136. 'play_path': video_play_path,
  137. 'page_url': video_page_url,
  138. 'player_url': video_player_url,
  139. 'ext': 'flv',
  140. 'title': video_title,
  141. 'description': video_description,
  142. 'upload_date': video_upload_date,
  143. 'thumbnail': video_thumbnail,
  144. }]