]>
Commit | Line | Data |
---|---|---|
b25b645d | 1 | # coding: utf-8 |
5d0a33ee AK |
2 | from __future__ import unicode_literals |
3 | ||
2ff7cbea S |
4 | import re |
5 | ||
5d0a33ee | 6 | from .common import InfoExtractor |
b25b645d | 7 | from ..compat import compat_str |
5d0a33ee AK |
8 | from ..utils import ( |
9 | ExtractorError, | |
cdc682d5 | 10 | determine_ext, |
5d0a33ee | 11 | int_or_none, |
b25b645d S |
12 | parse_iso8601, |
13 | parse_duration, | |
14 | remove_start, | |
5d0a33ee AK |
15 | ) |
16 | ||
5d0a33ee | 17 | |
2ff7cbea S |
18 | class NowTVBaseIE(InfoExtractor): |
19 | _VIDEO_FIELDS = ( | |
20 | 'id', 'title', 'free', 'geoblocked', 'articleLong', 'articleShort', | |
21 | 'broadcastStartDate', 'seoUrl', 'duration', 'files', | |
22 | 'format.defaultImage169Format', 'format.defaultImage169Logo') | |
23 | ||
24 | def _extract_video(self, info, display_id=None): | |
25 | video_id = compat_str(info['id']) | |
26 | ||
27 | files = info['files'] | |
28 | if not files: | |
29 | if info.get('geoblocked', False): | |
30 | raise ExtractorError( | |
31 | 'Video %s is not available from your location due to geo restriction' % video_id, | |
32 | expected=True) | |
33 | if not info.get('free', True): | |
34 | raise ExtractorError( | |
35 | 'Video %s is not available for free' % video_id, expected=True) | |
36 | ||
37 | formats = [] | |
38 | for item in files['items']: | |
39 | if determine_ext(item['path']) != 'f4v': | |
40 | continue | |
41 | app, play_path = remove_start(item['path'], '/').split('/', 1) | |
42 | formats.append({ | |
43 | 'url': 'rtmpe://fms.rtl.de', | |
44 | 'app': app, | |
45 | 'play_path': 'mp4:%s' % play_path, | |
46 | 'ext': 'flv', | |
47 | 'page_url': 'http://rtlnow.rtl.de', | |
48 | 'player_url': 'http://cdn.static-fra.de/now/vodplayer.swf', | |
49 | 'tbr': int_or_none(item.get('bitrate')), | |
50 | }) | |
51 | self._sort_formats(formats) | |
52 | ||
53 | title = info['title'] | |
54 | description = info.get('articleLong') or info.get('articleShort') | |
55 | timestamp = parse_iso8601(info.get('broadcastStartDate'), ' ') | |
56 | duration = parse_duration(info.get('duration')) | |
57 | ||
58 | f = info.get('format', {}) | |
59 | thumbnail = f.get('defaultImage169Format') or f.get('defaultImage169Logo') | |
60 | ||
61 | return { | |
62 | 'id': video_id, | |
63 | 'display_id': display_id or info.get('seoUrl'), | |
64 | 'title': title, | |
65 | 'description': description, | |
66 | 'thumbnail': thumbnail, | |
67 | 'timestamp': timestamp, | |
68 | 'duration': duration, | |
69 | 'formats': formats, | |
70 | } | |
71 | ||
72 | ||
73 | class NowTVIE(NowTVBaseIE): | |
ea6abd74 | 74 | _WORKING = False |
7d682f0a | 75 | _VALID_URL = r'https?://(?:www\.)?nowtv\.(?:de|at|ch)/(?:rtl|rtl2|rtlnitro|superrtl|ntv|vox)/(?P<show_id>[^/]+)/(?:(?:list/[^/]+|jahr/\d{4}/\d{1,2})/)?(?P<id>[^/]+)/(?:player|preview)' |
b25b645d S |
76 | |
77 | _TESTS = [{ | |
78 | # rtl | |
79 | 'url': 'http://www.nowtv.de/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/player', | |
80 | 'info_dict': { | |
81 | 'id': '203519', | |
82 | 'display_id': 'bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit', | |
cdc682d5 | 83 | 'ext': 'flv', |
2ff7cbea | 84 | 'title': 'Inka Bause stellt die neuen Bauern vor', |
b25b645d | 85 | 'description': 'md5:e234e1ed6d63cf06be5c070442612e7e', |
ec85ded8 | 86 | 'thumbnail': r're:^https?://.*\.jpg$', |
b25b645d S |
87 | 'timestamp': 1432580700, |
88 | 'upload_date': '20150525', | |
89 | 'duration': 2786, | |
90 | }, | |
91 | 'params': { | |
cdc682d5 | 92 | # rtmp download |
b25b645d S |
93 | 'skip_download': True, |
94 | }, | |
95 | }, { | |
96 | # rtl2 | |
97 | 'url': 'http://www.nowtv.de/rtl2/berlin-tag-nacht/berlin-tag-nacht-folge-934/player', | |
98 | 'info_dict': { | |
99 | 'id': '203481', | |
100 | 'display_id': 'berlin-tag-nacht/berlin-tag-nacht-folge-934', | |
cdc682d5 | 101 | 'ext': 'flv', |
b25b645d S |
102 | 'title': 'Berlin - Tag & Nacht (Folge 934)', |
103 | 'description': 'md5:c85e88c2e36c552dfe63433bc9506dd0', | |
ec85ded8 | 104 | 'thumbnail': r're:^https?://.*\.jpg$', |
b25b645d S |
105 | 'timestamp': 1432666800, |
106 | 'upload_date': '20150526', | |
107 | 'duration': 2641, | |
108 | }, | |
109 | 'params': { | |
cdc682d5 | 110 | # rtmp download |
b25b645d S |
111 | 'skip_download': True, |
112 | }, | |
9e0b5791 S |
113 | }, { |
114 | # rtlnitro | |
115 | 'url': 'http://www.nowtv.de/rtlnitro/alarm-fuer-cobra-11-die-autobahnpolizei/hals-und-beinbruch-2014-08-23-21-10-00/player', | |
116 | 'info_dict': { | |
117 | 'id': '165780', | |
118 | 'display_id': 'alarm-fuer-cobra-11-die-autobahnpolizei/hals-und-beinbruch-2014-08-23-21-10-00', | |
cdc682d5 | 119 | 'ext': 'flv', |
9e0b5791 S |
120 | 'title': 'Hals- und Beinbruch', |
121 | 'description': 'md5:b50d248efffe244e6f56737f0911ca57', | |
ec85ded8 | 122 | 'thumbnail': r're:^https?://.*\.jpg$', |
9e0b5791 S |
123 | 'timestamp': 1432415400, |
124 | 'upload_date': '20150523', | |
125 | 'duration': 2742, | |
126 | }, | |
127 | 'params': { | |
cdc682d5 | 128 | # rtmp download |
9e0b5791 S |
129 | 'skip_download': True, |
130 | }, | |
b25b645d S |
131 | }, { |
132 | # superrtl | |
133 | 'url': 'http://www.nowtv.de/superrtl/medicopter-117/angst/player', | |
134 | 'info_dict': { | |
135 | 'id': '99205', | |
136 | 'display_id': 'medicopter-117/angst', | |
cdc682d5 | 137 | 'ext': 'flv', |
b25b645d S |
138 | 'title': 'Angst!', |
139 | 'description': 'md5:30cbc4c0b73ec98bcd73c9f2a8c17c4e', | |
ec85ded8 | 140 | 'thumbnail': r're:^https?://.*\.jpg$', |
b25b645d S |
141 | 'timestamp': 1222632900, |
142 | 'upload_date': '20080928', | |
143 | 'duration': 3025, | |
144 | }, | |
145 | 'params': { | |
cdc682d5 | 146 | # rtmp download |
b25b645d S |
147 | 'skip_download': True, |
148 | }, | |
149 | }, { | |
150 | # ntv | |
151 | 'url': 'http://www.nowtv.de/ntv/ratgeber-geld/thema-ua-der-erste-blick-die-apple-watch/player', | |
152 | 'info_dict': { | |
153 | 'id': '203521', | |
154 | 'display_id': 'ratgeber-geld/thema-ua-der-erste-blick-die-apple-watch', | |
cdc682d5 | 155 | 'ext': 'flv', |
b25b645d S |
156 | 'title': 'Thema u.a.: Der erste Blick: Die Apple Watch', |
157 | 'description': 'md5:4312b6c9d839ffe7d8caf03865a531af', | |
ec85ded8 | 158 | 'thumbnail': r're:^https?://.*\.jpg$', |
b25b645d S |
159 | 'timestamp': 1432751700, |
160 | 'upload_date': '20150527', | |
161 | 'duration': 1083, | |
162 | }, | |
163 | 'params': { | |
cdc682d5 | 164 | # rtmp download |
b25b645d S |
165 | 'skip_download': True, |
166 | }, | |
167 | }, { | |
168 | # vox | |
169 | 'url': 'http://www.nowtv.de/vox/der-hundeprofi/buero-fall-chihuahua-joel/player', | |
170 | 'info_dict': { | |
171 | 'id': '128953', | |
172 | 'display_id': 'der-hundeprofi/buero-fall-chihuahua-joel', | |
cdc682d5 | 173 | 'ext': 'flv', |
b25b645d S |
174 | 'title': "Büro-Fall / Chihuahua 'Joel'", |
175 | 'description': 'md5:e62cb6bf7c3cc669179d4f1eb279ad8d', | |
ec85ded8 | 176 | 'thumbnail': r're:^https?://.*\.jpg$', |
b25b645d S |
177 | 'timestamp': 1432408200, |
178 | 'upload_date': '20150523', | |
179 | 'duration': 3092, | |
5d0a33ee | 180 | }, |
b25b645d | 181 | 'params': { |
cdc682d5 | 182 | # rtmp download |
b25b645d S |
183 | 'skip_download': True, |
184 | }, | |
e422d7f4 S |
185 | }, { |
186 | 'url': 'http://www.nowtv.de/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/preview', | |
187 | 'only_matching': True, | |
0f422256 S |
188 | }, { |
189 | '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', | |
190 | 'only_matching': True, | |
c88e118b S |
191 | }, { |
192 | 'url': 'http://www.nowtv.de/rtl2/echtzeit/list/aktuell/schnelles-geld-am-ende-der-welt/player', | |
193 | 'only_matching': True, | |
7d682f0a S |
194 | }, { |
195 | 'url': 'http://www.nowtv.de/rtl2/zuhause-im-glueck/jahr/2015/11/eine-erschuetternde-diagnose/player', | |
196 | 'only_matching': True, | |
b25b645d | 197 | }] |
5d0a33ee AK |
198 | |
199 | def _real_extract(self, url): | |
2ff7cbea S |
200 | mobj = re.match(self._VALID_URL, url) |
201 | display_id = '%s/%s' % (mobj.group('show_id'), mobj.group('id')) | |
5d0a33ee | 202 | |
b25b645d | 203 | info = self._download_json( |
2ff7cbea S |
204 | 'https://api.nowtv.de/v3/movies/%s?fields=%s' |
205 | % (display_id, ','.join(self._VIDEO_FIELDS)), display_id) | |
b25b645d | 206 | |
2ff7cbea | 207 | return self._extract_video(info, display_id) |
5d0a33ee | 208 | |
b25b645d | 209 | |
2ff7cbea S |
210 | class NowTVListIE(NowTVBaseIE): |
211 | _VALID_URL = r'https?://(?:www\.)?nowtv\.(?:de|at|ch)/(?:rtl|rtl2|rtlnitro|superrtl|ntv|vox)/(?P<show_id>[^/]+)/list/(?P<id>[^?/#&]+)$' | |
5d0a33ee | 212 | |
2ff7cbea S |
213 | _SHOW_FIELDS = ('title', ) |
214 | _SEASON_FIELDS = ('id', 'headline', 'seoheadline', ) | |
cdc682d5 | 215 | |
2ff7cbea S |
216 | _TESTS = [{ |
217 | 'url': 'http://www.nowtv.at/rtl/stern-tv/list/aktuell', | |
218 | 'info_dict': { | |
219 | 'id': '17006', | |
220 | 'title': 'stern TV - Aktuell', | |
221 | }, | |
222 | 'playlist_count': 1, | |
223 | }, { | |
224 | 'url': 'http://www.nowtv.at/rtl/das-supertalent/list/free-staffel-8', | |
225 | 'info_dict': { | |
226 | 'id': '20716', | |
227 | 'title': 'Das Supertalent - FREE Staffel 8', | |
228 | }, | |
229 | 'playlist_count': 14, | |
230 | }] | |
b25b645d | 231 | |
2ff7cbea S |
232 | def _real_extract(self, url): |
233 | mobj = re.match(self._VALID_URL, url) | |
234 | show_id = mobj.group('show_id') | |
235 | season_id = mobj.group('id') | |
236 | ||
237 | fields = [] | |
238 | fields.extend(self._SHOW_FIELDS) | |
239 | fields.extend('formatTabs.%s' % field for field in self._SEASON_FIELDS) | |
240 | fields.extend( | |
241 | 'formatTabs.formatTabPages.container.movies.%s' % field | |
242 | for field in self._VIDEO_FIELDS) | |
243 | ||
244 | list_info = self._download_json( | |
245 | 'https://api.nowtv.de/v3/formats/seo?fields=%s&name=%s.php' | |
246 | % (','.join(fields), show_id), | |
247 | season_id) | |
248 | ||
249 | season = next( | |
250 | season for season in list_info['formatTabs']['items'] | |
251 | if season.get('seoheadline') == season_id) | |
252 | ||
253 | title = '%s - %s' % (list_info['title'], season['headline']) | |
254 | ||
255 | entries = [] | |
256 | for container in season['formatTabPages']['items']: | |
257 | for info in ((container.get('container') or {}).get('movies') or {}).get('items') or []: | |
258 | entries.append(self._extract_video(info)) | |
259 | ||
260 | return self.playlist_result( | |
261 | entries, compat_str(season.get('id') or season_id), title) |