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.

184 lines
6.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import (
  6. ExtractorError,
  7. determine_ext,
  8. int_or_none,
  9. parse_iso8601,
  10. parse_duration,
  11. remove_start,
  12. )
  13. class NowTVIE(InfoExtractor):
  14. _VALID_URL = r'https?://(?:www\.)?nowtv\.de/(?:rtl|rtl2|rtlnitro|superrtl|ntv|vox)/(?P<id>.+?)/(?:player|preview)'
  15. _TESTS = [{
  16. # rtl
  17. 'url': 'http://www.nowtv.de/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/player',
  18. 'info_dict': {
  19. 'id': '203519',
  20. 'display_id': 'bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit',
  21. 'ext': 'flv',
  22. 'title': 'Die neuen Bauern und eine Hochzeit',
  23. 'description': 'md5:e234e1ed6d63cf06be5c070442612e7e',
  24. 'thumbnail': 're:^https?://.*\.jpg$',
  25. 'timestamp': 1432580700,
  26. 'upload_date': '20150525',
  27. 'duration': 2786,
  28. },
  29. 'params': {
  30. # rtmp download
  31. 'skip_download': True,
  32. },
  33. }, {
  34. # rtl2
  35. 'url': 'http://www.nowtv.de/rtl2/berlin-tag-nacht/berlin-tag-nacht-folge-934/player',
  36. 'info_dict': {
  37. 'id': '203481',
  38. 'display_id': 'berlin-tag-nacht/berlin-tag-nacht-folge-934',
  39. 'ext': 'flv',
  40. 'title': 'Berlin - Tag & Nacht (Folge 934)',
  41. 'description': 'md5:c85e88c2e36c552dfe63433bc9506dd0',
  42. 'thumbnail': 're:^https?://.*\.jpg$',
  43. 'timestamp': 1432666800,
  44. 'upload_date': '20150526',
  45. 'duration': 2641,
  46. },
  47. 'params': {
  48. # rtmp download
  49. 'skip_download': True,
  50. },
  51. }, {
  52. # rtlnitro
  53. 'url': 'http://www.nowtv.de/rtlnitro/alarm-fuer-cobra-11-die-autobahnpolizei/hals-und-beinbruch-2014-08-23-21-10-00/player',
  54. 'info_dict': {
  55. 'id': '165780',
  56. 'display_id': 'alarm-fuer-cobra-11-die-autobahnpolizei/hals-und-beinbruch-2014-08-23-21-10-00',
  57. 'ext': 'flv',
  58. 'title': 'Hals- und Beinbruch',
  59. 'description': 'md5:b50d248efffe244e6f56737f0911ca57',
  60. 'thumbnail': 're:^https?://.*\.jpg$',
  61. 'timestamp': 1432415400,
  62. 'upload_date': '20150523',
  63. 'duration': 2742,
  64. },
  65. 'params': {
  66. # rtmp download
  67. 'skip_download': True,
  68. },
  69. }, {
  70. # superrtl
  71. 'url': 'http://www.nowtv.de/superrtl/medicopter-117/angst/player',
  72. 'info_dict': {
  73. 'id': '99205',
  74. 'display_id': 'medicopter-117/angst',
  75. 'ext': 'flv',
  76. 'title': 'Angst!',
  77. 'description': 'md5:30cbc4c0b73ec98bcd73c9f2a8c17c4e',
  78. 'thumbnail': 're:^https?://.*\.jpg$',
  79. 'timestamp': 1222632900,
  80. 'upload_date': '20080928',
  81. 'duration': 3025,
  82. },
  83. 'params': {
  84. # rtmp download
  85. 'skip_download': True,
  86. },
  87. }, {
  88. # ntv
  89. 'url': 'http://www.nowtv.de/ntv/ratgeber-geld/thema-ua-der-erste-blick-die-apple-watch/player',
  90. 'info_dict': {
  91. 'id': '203521',
  92. 'display_id': 'ratgeber-geld/thema-ua-der-erste-blick-die-apple-watch',
  93. 'ext': 'flv',
  94. 'title': 'Thema u.a.: Der erste Blick: Die Apple Watch',
  95. 'description': 'md5:4312b6c9d839ffe7d8caf03865a531af',
  96. 'thumbnail': 're:^https?://.*\.jpg$',
  97. 'timestamp': 1432751700,
  98. 'upload_date': '20150527',
  99. 'duration': 1083,
  100. },
  101. 'params': {
  102. # rtmp download
  103. 'skip_download': True,
  104. },
  105. }, {
  106. # vox
  107. 'url': 'http://www.nowtv.de/vox/der-hundeprofi/buero-fall-chihuahua-joel/player',
  108. 'info_dict': {
  109. 'id': '128953',
  110. 'display_id': 'der-hundeprofi/buero-fall-chihuahua-joel',
  111. 'ext': 'flv',
  112. 'title': "Büro-Fall / Chihuahua 'Joel'",
  113. 'description': 'md5:e62cb6bf7c3cc669179d4f1eb279ad8d',
  114. 'thumbnail': 're:^https?://.*\.jpg$',
  115. 'timestamp': 1432408200,
  116. 'upload_date': '20150523',
  117. 'duration': 3092,
  118. },
  119. 'params': {
  120. # rtmp download
  121. 'skip_download': True,
  122. },
  123. }, {
  124. 'url': 'http://www.nowtv.de/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/preview',
  125. 'only_matching': True,
  126. }]
  127. def _real_extract(self, url):
  128. display_id = self._match_id(url)
  129. info = self._download_json(
  130. 'https://api.nowtv.de/v3/movies/%s?fields=id,title,free,geoblocked,articleLong,articleShort,broadcastStartDate,seoUrl,duration,format,files' % display_id,
  131. display_id)
  132. video_id = compat_str(info['id'])
  133. files = info['files']
  134. if not files:
  135. if info.get('geoblocked', False):
  136. raise ExtractorError(
  137. 'Video %s is not available from your location due to geo restriction' % video_id,
  138. expected=True)
  139. if not info.get('free', True):
  140. raise ExtractorError(
  141. 'Video %s is not available for free' % video_id, expected=True)
  142. formats = []
  143. for item in files['items']:
  144. if determine_ext(item['path']) != 'f4v':
  145. continue
  146. app, play_path = remove_start(item['path'], '/').split('/', 1)
  147. formats.append({
  148. 'url': 'rtmpe://fms.rtl.de',
  149. 'app': app,
  150. 'play_path': 'mp4:%s' % play_path,
  151. 'ext': 'flv',
  152. 'page_url': url,
  153. 'player_url': 'http://rtl-now.rtl.de/includes/nc_player.swf',
  154. 'tbr': int_or_none(item.get('bitrate')),
  155. })
  156. self._sort_formats(formats)
  157. title = info['title']
  158. description = info.get('articleLong') or info.get('articleShort')
  159. timestamp = parse_iso8601(info.get('broadcastStartDate'), ' ')
  160. duration = parse_duration(info.get('duration'))
  161. f = info.get('format', {})
  162. thumbnail = f.get('defaultImage169Format') or f.get('defaultImage169Logo')
  163. return {
  164. 'id': video_id,
  165. 'display_id': display_id,
  166. 'title': title,
  167. 'description': description,
  168. 'thumbnail': thumbnail,
  169. 'timestamp': timestamp,
  170. 'duration': duration,
  171. 'formats': formats,
  172. }