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.

193 lines
6.9 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. 'url': 'http://www.nowtv.de/rtl2/echtzeit/list/aktuell/schnelles-geld-am-ende-der-welt/player',
  131. 'only_matching': True,
  132. }]
  133. def _real_extract(self, url):
  134. display_id = self._match_id(url)
  135. display_id_split = display_id.split('/')
  136. if len(display_id) > 2:
  137. display_id = '/'.join((display_id_split[0], display_id_split[-1]))
  138. info = self._download_json(
  139. 'https://api.nowtv.de/v3/movies/%s?fields=id,title,free,geoblocked,articleLong,articleShort,broadcastStartDate,seoUrl,duration,format,files' % display_id,
  140. display_id)
  141. video_id = compat_str(info['id'])
  142. files = info['files']
  143. if not files:
  144. if info.get('geoblocked', False):
  145. raise ExtractorError(
  146. 'Video %s is not available from your location due to geo restriction' % video_id,
  147. expected=True)
  148. if not info.get('free', True):
  149. raise ExtractorError(
  150. 'Video %s is not available for free' % video_id, expected=True)
  151. formats = []
  152. for item in files['items']:
  153. if determine_ext(item['path']) != 'f4v':
  154. continue
  155. app, play_path = remove_start(item['path'], '/').split('/', 1)
  156. formats.append({
  157. 'url': 'rtmpe://fms.rtl.de',
  158. 'app': app,
  159. 'play_path': 'mp4:%s' % play_path,
  160. 'ext': 'flv',
  161. 'page_url': url,
  162. 'player_url': 'http://rtl-now.rtl.de/includes/nc_player.swf',
  163. 'tbr': int_or_none(item.get('bitrate')),
  164. })
  165. self._sort_formats(formats)
  166. title = info['title']
  167. description = info.get('articleLong') or info.get('articleShort')
  168. timestamp = parse_iso8601(info.get('broadcastStartDate'), ' ')
  169. duration = parse_duration(info.get('duration'))
  170. f = info.get('format', {})
  171. thumbnail = f.get('defaultImage169Format') or f.get('defaultImage169Logo')
  172. return {
  173. 'id': video_id,
  174. 'display_id': display_id,
  175. 'title': title,
  176. 'description': description,
  177. 'thumbnail': thumbnail,
  178. 'timestamp': timestamp,
  179. 'duration': duration,
  180. 'formats': formats,
  181. }