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.

187 lines
6.6 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|at|ch)/(?: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. 'url': 'http://www.nowtv.at/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/preview?return=/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit',
  128. 'only_matching': True,
  129. }]
  130. def _real_extract(self, url):
  131. display_id = self._match_id(url)
  132. info = self._download_json(
  133. 'https://api.nowtv.de/v3/movies/%s?fields=id,title,free,geoblocked,articleLong,articleShort,broadcastStartDate,seoUrl,duration,format,files' % display_id,
  134. display_id)
  135. video_id = compat_str(info['id'])
  136. files = info['files']
  137. if not files:
  138. if info.get('geoblocked', False):
  139. raise ExtractorError(
  140. 'Video %s is not available from your location due to geo restriction' % video_id,
  141. expected=True)
  142. if not info.get('free', True):
  143. raise ExtractorError(
  144. 'Video %s is not available for free' % video_id, expected=True)
  145. formats = []
  146. for item in files['items']:
  147. if determine_ext(item['path']) != 'f4v':
  148. continue
  149. app, play_path = remove_start(item['path'], '/').split('/', 1)
  150. formats.append({
  151. 'url': 'rtmpe://fms.rtl.de',
  152. 'app': app,
  153. 'play_path': 'mp4:%s' % play_path,
  154. 'ext': 'flv',
  155. 'page_url': url,
  156. 'player_url': 'http://rtl-now.rtl.de/includes/nc_player.swf',
  157. 'tbr': int_or_none(item.get('bitrate')),
  158. })
  159. self._sort_formats(formats)
  160. title = info['title']
  161. description = info.get('articleLong') or info.get('articleShort')
  162. timestamp = parse_iso8601(info.get('broadcastStartDate'), ' ')
  163. duration = parse_duration(info.get('duration'))
  164. f = info.get('format', {})
  165. thumbnail = f.get('defaultImage169Format') or f.get('defaultImage169Logo')
  166. return {
  167. 'id': video_id,
  168. 'display_id': display_id,
  169. 'title': title,
  170. 'description': description,
  171. 'thumbnail': thumbnail,
  172. 'timestamp': timestamp,
  173. 'duration': duration,
  174. 'formats': formats,
  175. }