]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
0c7214c4 S |
2 | from __future__ import unicode_literals |
3 | ||
4 | import re | |
5 | ||
6 | from hashlib import sha1 | |
7 | from .common import InfoExtractor | |
84f214d8 | 8 | from ..compat import compat_str |
1cc79574 | 9 | from ..utils import ( |
61be92e2 | 10 | ExtractorError, |
f01f7311 | 11 | determine_ext, |
993df6bc | 12 | float_or_none, |
01534bf5 | 13 | int_or_none, |
2af0f87c | 14 | unified_strdate, |
0c7214c4 S |
15 | ) |
16 | ||
17 | ||
9d54b02b | 18 | class ProSiebenSat1BaseIE(InfoExtractor): |
0c15a56f | 19 | _GEO_BYPASS = False |
c5eb75b3 RA |
20 | _ACCESS_ID = None |
21 | _SUPPORTED_PROTOCOLS = 'dash:clear,hls:clear,progressive:clear' | |
22 | _V4_BASE_URL = 'https://vas-v4.p7s1video.net/4.0/get' | |
23 | ||
9d54b02b RA |
24 | def _extract_video_info(self, url, clip_id): |
25 | client_location = url | |
26 | ||
27 | video = self._download_json( | |
28 | 'http://vas.sim-technik.de/vas/live/v2/videos', | |
29 | clip_id, 'Downloading videos JSON', query={ | |
30 | 'access_token': self._TOKEN, | |
31 | 'client_location': client_location, | |
32 | 'client_name': self._CLIENT_NAME, | |
33 | 'ids': clip_id, | |
34 | })[0] | |
35 | ||
36 | if video.get('is_protected') is True: | |
37 | raise ExtractorError('This video is DRM protected.', expected=True) | |
38 | ||
c5eb75b3 RA |
39 | formats = [] |
40 | if self._ACCESS_ID: | |
41 | raw_ct = self._ENCRYPTION_KEY + clip_id + self._IV + self._ACCESS_ID | |
0c15a56f | 42 | protocols = self._download_json( |
c5eb75b3 RA |
43 | self._V4_BASE_URL + 'protocols', clip_id, |
44 | 'Downloading protocols JSON', | |
45 | headers=self.geo_verification_headers(), query={ | |
46 | 'access_id': self._ACCESS_ID, | |
47 | 'client_token': sha1((raw_ct).encode()).hexdigest(), | |
48 | 'video_id': clip_id, | |
0c15a56f RA |
49 | }, fatal=False, expected_status=(403,)) or {} |
50 | error = protocols.get('error') or {} | |
51 | if error.get('title') == 'Geo check failed': | |
52 | self.raise_geo_restricted(countries=['AT', 'CH', 'DE']) | |
53 | server_token = protocols.get('server_token') | |
c5eb75b3 RA |
54 | if server_token: |
55 | urls = (self._download_json( | |
56 | self._V4_BASE_URL + 'urls', clip_id, 'Downloading urls JSON', query={ | |
57 | 'access_id': self._ACCESS_ID, | |
58 | 'client_token': sha1((raw_ct + server_token + self._SUPPORTED_PROTOCOLS).encode()).hexdigest(), | |
59 | 'protocols': self._SUPPORTED_PROTOCOLS, | |
60 | 'server_token': server_token, | |
61 | 'video_id': clip_id, | |
62 | }, fatal=False) or {}).get('urls') or {} | |
63 | for protocol, variant in urls.items(): | |
64 | source_url = variant.get('clear', {}).get('url') | |
65 | if not source_url: | |
66 | continue | |
67 | if protocol == 'dash': | |
68 | formats.extend(self._extract_mpd_formats( | |
69 | source_url, clip_id, mpd_id=protocol, fatal=False)) | |
70 | elif protocol == 'hls': | |
71 | formats.extend(self._extract_m3u8_formats( | |
72 | source_url, clip_id, 'mp4', 'm3u8_native', | |
73 | m3u8_id=protocol, fatal=False)) | |
74 | else: | |
75 | formats.append({ | |
76 | 'url': source_url, | |
77 | 'format_id': protocol, | |
78 | }) | |
79 | if not formats: | |
80 | source_ids = [compat_str(source['id']) for source in video['sources']] | |
9d54b02b | 81 | |
c5eb75b3 | 82 | client_id = self._SALT[:2] + sha1(''.join([clip_id, self._SALT, self._TOKEN, client_location, self._SALT, self._CLIENT_NAME]).encode('utf-8')).hexdigest() |
9d54b02b | 83 | |
c5eb75b3 RA |
84 | sources = self._download_json( |
85 | 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources' % clip_id, | |
86 | clip_id, 'Downloading sources JSON', query={ | |
9d54b02b RA |
87 | 'access_token': self._TOKEN, |
88 | 'client_id': client_id, | |
89 | 'client_location': client_location, | |
90 | 'client_name': self._CLIENT_NAME, | |
9d54b02b | 91 | }) |
c5eb75b3 RA |
92 | server_id = sources['server_id'] |
93 | ||
94 | def fix_bitrate(bitrate): | |
95 | bitrate = int_or_none(bitrate) | |
96 | if not bitrate: | |
97 | return None | |
98 | return (bitrate // 1000) if bitrate % 1000 == 0 else bitrate | |
99 | ||
100 | for source_id in source_ids: | |
101 | client_id = self._SALT[:2] + sha1(''.join([self._SALT, clip_id, self._TOKEN, server_id, client_location, source_id, self._SALT, self._CLIENT_NAME]).encode('utf-8')).hexdigest() | |
102 | urls = self._download_json( | |
103 | 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url' % clip_id, | |
104 | clip_id, 'Downloading urls JSON', fatal=False, query={ | |
105 | 'access_token': self._TOKEN, | |
106 | 'client_id': client_id, | |
107 | 'client_location': client_location, | |
108 | 'client_name': self._CLIENT_NAME, | |
109 | 'server_id': server_id, | |
110 | 'source_ids': source_id, | |
111 | }) | |
112 | if not urls: | |
9d54b02b | 113 | continue |
c5eb75b3 RA |
114 | if urls.get('status_code') != 0: |
115 | raise ExtractorError('This video is unavailable', expected=True) | |
116 | urls_sources = urls['sources'] | |
117 | if isinstance(urls_sources, dict): | |
118 | urls_sources = urls_sources.values() | |
119 | for source in urls_sources: | |
120 | source_url = source.get('url') | |
121 | if not source_url: | |
122 | continue | |
123 | protocol = source.get('protocol') | |
124 | mimetype = source.get('mimetype') | |
125 | if mimetype == 'application/f4m+xml' or 'f4mgenerator' in source_url or determine_ext(source_url) == 'f4m': | |
126 | formats.extend(self._extract_f4m_formats( | |
127 | source_url, clip_id, f4m_id='hds', fatal=False)) | |
128 | elif mimetype == 'application/x-mpegURL': | |
129 | formats.extend(self._extract_m3u8_formats( | |
130 | source_url, clip_id, 'mp4', 'm3u8_native', | |
131 | m3u8_id='hls', fatal=False)) | |
132 | elif mimetype == 'application/dash+xml': | |
133 | formats.extend(self._extract_mpd_formats( | |
134 | source_url, clip_id, mpd_id='dash', fatal=False)) | |
9d54b02b | 135 | else: |
c5eb75b3 RA |
136 | tbr = fix_bitrate(source['bitrate']) |
137 | if protocol in ('rtmp', 'rtmpe'): | |
138 | mobj = re.search(r'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url) | |
139 | if not mobj: | |
140 | continue | |
141 | path = mobj.group('path') | |
142 | mp4colon_index = path.rfind('mp4:') | |
143 | app = path[:mp4colon_index] | |
144 | play_path = path[mp4colon_index:] | |
145 | formats.append({ | |
146 | 'url': '%s/%s' % (mobj.group('url'), app), | |
147 | 'app': app, | |
148 | 'play_path': play_path, | |
149 | 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf', | |
150 | 'page_url': 'http://www.prosieben.de', | |
151 | 'tbr': tbr, | |
152 | 'ext': 'flv', | |
153 | 'format_id': 'rtmp%s' % ('-%d' % tbr if tbr else ''), | |
154 | }) | |
155 | else: | |
156 | formats.append({ | |
157 | 'url': source_url, | |
158 | 'tbr': tbr, | |
159 | 'format_id': 'http%s' % ('-%d' % tbr if tbr else ''), | |
160 | }) | |
9d54b02b RA |
161 | self._sort_formats(formats) |
162 | ||
163 | return { | |
c5eb75b3 | 164 | 'duration': float_or_none(video.get('duration')), |
9d54b02b RA |
165 | 'formats': formats, |
166 | } | |
167 | ||
168 | ||
169 | class ProSiebenSat1IE(ProSiebenSat1BaseIE): | |
0c7214c4 S |
170 | IE_NAME = 'prosiebensat1' |
171 | IE_DESC = 'ProSiebenSat.1 Digital' | |
63c583eb S |
172 | _VALID_URL = r'''(?x) |
173 | https?:// | |
174 | (?:www\.)? | |
175 | (?: | |
5a586082 | 176 | (?:beta\.)? |
63c583eb | 177 | (?: |
493353c7 | 178 | prosieben(?:maxx)?|sixx|sat1(?:gold)?|kabeleins(?:doku)?|the-voice-of-germany|7tv|advopedia |
63c583eb | 179 | )\.(?:de|at|ch)| |
6e3f23d9 | 180 | ran\.de|fem\.com|advopedia\.de|galileo\.tv/video |
63c583eb S |
181 | ) |
182 | /(?P<id>.+) | |
183 | ''' | |
0c7214c4 S |
184 | |
185 | _TESTS = [ | |
186 | { | |
067aa17e S |
187 | # Tests changes introduced in https://github.com/ytdl-org/youtube-dl/pull/6242 |
188 | # in response to fixing https://github.com/ytdl-org/youtube-dl/issues/6215: | |
ab9b890b S |
189 | # - malformed f4m manifest support |
190 | # - proper handling of URLs starting with `https?://` in 2.0 manifests | |
191 | # - recursive child f4m manifests extraction | |
0c7214c4 S |
192 | 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', |
193 | 'info_dict': { | |
194 | 'id': '2104602', | |
fe5aa197 | 195 | 'ext': 'mp4', |
16fa0129 | 196 | 'title': 'Episode 18 - Staffel 2', |
0c7214c4 S |
197 | 'description': 'md5:8733c81b702ea472e069bc48bb658fc1', |
198 | 'upload_date': '20131231', | |
199 | 'duration': 5845.04, | |
200 | }, | |
0c7214c4 S |
201 | }, |
202 | { | |
203 | 'url': 'http://www.prosieben.de/videokatalog/Gesellschaft/Leben/Trends/video-Lady-Umstyling-f%C3%BCr-Audrina-Rebekka-Audrina-Fergen-billig-aussehen-Battal-Modica-700544.html', | |
204 | 'info_dict': { | |
205 | 'id': '2570327', | |
206 | 'ext': 'mp4', | |
207 | 'title': 'Lady-Umstyling für Audrina', | |
208 | 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d', | |
209 | 'upload_date': '20131014', | |
210 | 'duration': 606.76, | |
211 | }, | |
212 | 'params': { | |
213 | # rtmp download | |
214 | 'skip_download': True, | |
215 | }, | |
216 | 'skip': 'Seems to be broken', | |
217 | }, | |
218 | { | |
6dadaa99 | 219 | 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge', |
0c7214c4 | 220 | 'info_dict': { |
6dadaa99 | 221 | 'id': '2429369', |
0c7214c4 | 222 | 'ext': 'mp4', |
6dadaa99 S |
223 | 'title': 'Countdown für die Autowerkstatt', |
224 | 'description': 'md5:809fc051a457b5d8666013bc40698817', | |
225 | 'upload_date': '20140223', | |
226 | 'duration': 2595.04, | |
0c7214c4 S |
227 | }, |
228 | 'params': { | |
229 | # rtmp download | |
230 | 'skip_download': True, | |
231 | }, | |
84f214d8 | 232 | 'skip': 'This video is unavailable', |
0c7214c4 S |
233 | }, |
234 | { | |
235 | 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip', | |
236 | 'info_dict': { | |
237 | 'id': '2904997', | |
238 | 'ext': 'mp4', | |
239 | 'title': 'Sexy laufen in Ugg Boots', | |
240 | 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6', | |
241 | 'upload_date': '20140122', | |
242 | 'duration': 245.32, | |
243 | }, | |
244 | 'params': { | |
245 | # rtmp download | |
246 | 'skip_download': True, | |
247 | }, | |
84f214d8 | 248 | 'skip': 'This video is unavailable', |
0c7214c4 S |
249 | }, |
250 | { | |
251 | 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip', | |
252 | 'info_dict': { | |
253 | 'id': '2906572', | |
254 | 'ext': 'mp4', | |
255 | 'title': 'Im Interview: Kai Wiesinger', | |
256 | 'description': 'md5:e4e5370652ec63b95023e914190b4eb9', | |
8d1c8cae | 257 | 'upload_date': '20140203', |
0c7214c4 S |
258 | 'duration': 522.56, |
259 | }, | |
260 | 'params': { | |
261 | # rtmp download | |
262 | 'skip_download': True, | |
263 | }, | |
84f214d8 | 264 | 'skip': 'This video is unavailable', |
0c7214c4 S |
265 | }, |
266 | { | |
267 | 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge', | |
268 | 'info_dict': { | |
269 | 'id': '2992323', | |
270 | 'ext': 'mp4', | |
271 | 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2', | |
272 | 'description': 'md5:2669cde3febe9bce13904f701e774eb6', | |
8d1c8cae | 273 | 'upload_date': '20141014', |
0c7214c4 S |
274 | 'duration': 2410.44, |
275 | }, | |
276 | 'params': { | |
277 | # rtmp download | |
278 | 'skip_download': True, | |
279 | }, | |
84f214d8 | 280 | 'skip': 'This video is unavailable', |
0c7214c4 S |
281 | }, |
282 | { | |
283 | 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge', | |
284 | 'info_dict': { | |
285 | 'id': '3004256', | |
286 | 'ext': 'mp4', | |
287 | 'title': 'Schalke: Tönnies möchte Raul zurück', | |
288 | 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f', | |
289 | 'upload_date': '20140226', | |
290 | 'duration': 228.96, | |
291 | }, | |
292 | 'params': { | |
293 | # rtmp download | |
294 | 'skip_download': True, | |
295 | }, | |
84f214d8 | 296 | 'skip': 'This video is unavailable', |
0c7214c4 S |
297 | }, |
298 | { | |
299 | 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip', | |
300 | 'info_dict': { | |
301 | 'id': '2572814', | |
fe5aa197 | 302 | 'ext': 'mp4', |
0c7214c4 S |
303 | 'title': 'Andreas Kümmert: Rocket Man', |
304 | 'description': 'md5:6ddb02b0781c6adf778afea606652e38', | |
305 | 'upload_date': '20131017', | |
306 | 'duration': 469.88, | |
307 | }, | |
308 | 'params': { | |
0c7214c4 S |
309 | 'skip_download': True, |
310 | }, | |
311 | }, | |
312 | { | |
313 | 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html', | |
314 | 'info_dict': { | |
315 | 'id': '2156342', | |
fe5aa197 | 316 | 'ext': 'mp4', |
0c7214c4 | 317 | 'title': 'Kurztrips zum Valentinstag', |
81549898 | 318 | 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.', |
0c7214c4 S |
319 | 'duration': 307.24, |
320 | }, | |
321 | 'params': { | |
0c7214c4 S |
322 | 'skip_download': True, |
323 | }, | |
324 | }, | |
c84890f7 AK |
325 | { |
326 | 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist', | |
327 | 'info_dict': { | |
328 | 'id': '439664', | |
329 | 'title': 'Episode 8 - Ganze Folge - Playlist', | |
6a52eed8 | 330 | 'description': 'md5:63b8963e71f481782aeea877658dec84', |
c84890f7 AK |
331 | }, |
332 | 'playlist_count': 2, | |
fe5aa197 | 333 | 'skip': 'This video is unavailable', |
c84890f7 | 334 | }, |
0baedd18 L |
335 | { |
336 | 'url': 'http://www.7tv.de/circus-halligalli/615-best-of-circus-halligalli-ganze-folge', | |
337 | 'info_dict': { | |
338 | 'id': '4187506', | |
fe5aa197 | 339 | 'ext': 'mp4', |
0baedd18 L |
340 | 'title': 'Best of Circus HalliGalli', |
341 | 'description': 'md5:8849752efd90b9772c9db6fdf87fb9e9', | |
342 | 'upload_date': '20151229', | |
343 | }, | |
344 | 'params': { | |
0baedd18 L |
345 | 'skip_download': True, |
346 | }, | |
347 | }, | |
76bee08f S |
348 | { |
349 | # title in <h2 class="subtitle"> | |
350 | 'url': 'http://www.prosieben.de/stars/oscar-award/videos/jetzt-erst-enthuellt-das-geheimnis-von-emma-stones-oscar-robe-clip', | |
351 | 'info_dict': { | |
352 | 'id': '4895826', | |
353 | 'ext': 'mp4', | |
354 | 'title': 'Jetzt erst enthüllt: Das Geheimnis von Emma Stones Oscar-Robe', | |
355 | 'description': 'md5:e5ace2bc43fadf7b63adc6187e9450b9', | |
356 | 'upload_date': '20170302', | |
357 | }, | |
358 | 'params': { | |
359 | 'skip_download': True, | |
360 | }, | |
361 | 'skip': 'geo restricted to Germany', | |
362 | }, | |
71ad00c0 S |
363 | { |
364 | # geo restricted to Germany | |
365 | 'url': 'http://www.kabeleinsdoku.de/tv/mayday-alarm-im-cockpit/video/102-notlandung-im-hudson-river-ganze-folge', | |
366 | 'only_matching': True, | |
367 | }, | |
63c583eb S |
368 | { |
369 | # geo restricted to Germany | |
370 | 'url': 'http://www.sat1gold.de/tv/edel-starck/video/11-staffel-1-episode-1-partner-wider-willen-ganze-folge', | |
371 | 'only_matching': True, | |
372 | }, | |
6e3f23d9 | 373 | { |
374 | # geo restricted to Germany | |
375 | 'url': 'https://www.galileo.tv/video/diese-emojis-werden-oft-missverstanden', | |
376 | 'only_matching': True, | |
377 | }, | |
ddde9195 S |
378 | { |
379 | 'url': 'http://www.sat1gold.de/tv/edel-starck/playlist/die-gesamte-1-staffel', | |
380 | 'only_matching': True, | |
381 | }, | |
493353c7 S |
382 | { |
383 | 'url': 'http://www.advopedia.de/videos/lenssen-klaert-auf/lenssen-klaert-auf-folge-8-staffel-3-feiertage-und-freie-tage', | |
384 | 'only_matching': True, | |
385 | }, | |
0c7214c4 S |
386 | ] |
387 | ||
9d54b02b RA |
388 | _TOKEN = 'prosieben' |
389 | _SALT = '01!8d8F_)r9]4s[qeuXfP%' | |
390 | _CLIENT_NAME = 'kolibri-2.0.19-splec4' | |
c5eb75b3 RA |
391 | |
392 | _ACCESS_ID = 'x_prosiebenmaxx-de' | |
393 | _ENCRYPTION_KEY = 'Eeyeey9oquahthainoofashoyoikosag' | |
394 | _IV = 'Aeluchoc6aevechuipiexeeboowedaok' | |
395 | ||
0c7214c4 S |
396 | _CLIPID_REGEXES = [ |
397 | r'"clip_id"\s*:\s+"(\d+)"', | |
398 | r'clipid: "(\d+)"', | |
38a9339b | 399 | r'clip[iI]d=(\d+)', |
6e3f23d9 | 400 | r'clip[iI][dD]\s*=\s*["\'](\d+)', |
8d1c8cae | 401 | r"'itemImageUrl'\s*:\s*'/dynamic/thumbnails/full/\d+/(\d+)", |
721a0c3c | 402 | r'proMamsId"\s*:\s*"(\d+)', |
967ebbdb | 403 | r'proMamsId"\s*:\s*"(\d+)', |
0c7214c4 S |
404 | ] |
405 | _TITLE_REGEXES = [ | |
406 | r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>', | |
407 | r'<header class="clearfix">\s*<h3>(.+?)</h3>', | |
408 | r'<!-- start video -->\s*<h1>(.+?)</h1>', | |
38a9339b | 409 | r'<h1 class="att-name">\s*(.+?)</h1>', |
8b6c896c | 410 | r'<header class="module_header">\s*<h2>([^<]+)</h2>\s*</header>', |
0baedd18 | 411 | r'<h2 class="video-title" itemprop="name">\s*(.+?)</h2>', |
81549898 | 412 | r'<div[^>]+id="veeseoTitle"[^>]*>(.+?)</div>', |
76bee08f | 413 | r'<h2[^>]+class="subtitle"[^>]*>([^<]+)</h2>', |
0c7214c4 S |
414 | ] |
415 | _DESCRIPTION_REGEXES = [ | |
416 | r'<p itemprop="description">\s*(.+?)</p>', | |
417 | r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>', | |
418 | r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>', | |
38a9339b | 419 | r'<p class="att-description">\s*(.+?)\s*</p>', |
0baedd18 | 420 | r'<p class="video-description" itemprop="description">\s*(.+?)</p>', |
81549898 | 421 | r'<div[^>]+id="veeseoDescription"[^>]*>(.+?)</div>', |
0c7214c4 S |
422 | ] |
423 | _UPLOAD_DATE_REGEXES = [ | |
424 | r'<meta property="og:published_time" content="(.+?)">', | |
425 | r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"', | |
426 | r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr', | |
427 | r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>', | |
428 | r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>', | |
429 | ] | |
6a52eed8 S |
430 | _PAGE_TYPE_REGEXES = [ |
431 | r'<meta name="page_type" content="([^"]+)">', | |
c84890f7 AK |
432 | r"'itemType'\s*:\s*'([^']*)'", |
433 | ] | |
6a52eed8 S |
434 | _PLAYLIST_ID_REGEXES = [ |
435 | r'content[iI]d=(\d+)', | |
c84890f7 AK |
436 | r"'itemId'\s*:\s*'([^']*)'", |
437 | ] | |
6a52eed8 S |
438 | _PLAYLIST_CLIP_REGEXES = [ |
439 | r'(?s)data-qvt=.+?<a href="([^"]+)"', | |
c84890f7 | 440 | ] |
0c7214c4 | 441 | |
6a52eed8 | 442 | def _extract_clip(self, url, webpage): |
84f214d8 RA |
443 | clip_id = self._html_search_regex( |
444 | self._CLIPID_REGEXES, webpage, 'clip id') | |
76bee08f S |
445 | title = self._html_search_regex( |
446 | self._TITLE_REGEXES, webpage, 'title', | |
447 | default=None) or self._og_search_title(webpage) | |
9d54b02b | 448 | info = self._extract_video_info(url, clip_id) |
84f214d8 | 449 | description = self._html_search_regex( |
7882f111 | 450 | self._DESCRIPTION_REGEXES, webpage, 'description', default=None) |
fe5aa197 | 451 | if description is None: |
7882f111 | 452 | description = self._og_search_description(webpage) |
84f214d8 RA |
453 | thumbnail = self._og_search_thumbnail(webpage) |
454 | upload_date = unified_strdate(self._html_search_regex( | |
455 | self._UPLOAD_DATE_REGEXES, webpage, 'upload date', default=None)) | |
456 | ||
9d54b02b | 457 | info.update({ |
0c7214c4 S |
458 | 'id': clip_id, |
459 | 'title': title, | |
460 | 'description': description, | |
461 | 'thumbnail': thumbnail, | |
462 | 'upload_date': upload_date, | |
9d54b02b RA |
463 | }) |
464 | return info | |
6a52eed8 S |
465 | |
466 | def _extract_playlist(self, url, webpage): | |
467 | playlist_id = self._html_search_regex( | |
468 | self._PLAYLIST_ID_REGEXES, webpage, 'playlist id') | |
ddde9195 S |
469 | playlist = self._parse_json( |
470 | self._search_regex( | |
ec85ded8 | 471 | r'var\s+contentResources\s*=\s*(\[.+?\]);\s*</script', |
ddde9195 S |
472 | webpage, 'playlist'), |
473 | playlist_id) | |
474 | entries = [] | |
475 | for item in playlist: | |
476 | clip_id = item.get('id') or item.get('upc') | |
477 | if not clip_id: | |
478 | continue | |
479 | info = self._extract_video_info(url, clip_id) | |
480 | info.update({ | |
481 | 'id': clip_id, | |
482 | 'title': item.get('title') or item.get('teaser', {}).get('headline'), | |
483 | 'description': item.get('teaser', {}).get('description'), | |
484 | 'thumbnail': item.get('poster'), | |
485 | 'duration': float_or_none(item.get('duration')), | |
486 | 'series': item.get('tvShowTitle'), | |
487 | 'uploader': item.get('broadcastPublisher'), | |
488 | }) | |
489 | entries.append(info) | |
490 | return self.playlist_result(entries, playlist_id) | |
6a52eed8 S |
491 | |
492 | def _real_extract(self, url): | |
493 | video_id = self._match_id(url) | |
494 | webpage = self._download_webpage(url, video_id) | |
495 | page_type = self._search_regex( | |
496 | self._PAGE_TYPE_REGEXES, webpage, | |
497 | 'page type', default='clip').lower() | |
498 | if page_type == 'clip': | |
499 | return self._extract_clip(url, webpage) | |
500 | elif page_type == 'playlist': | |
501 | return self._extract_playlist(url, webpage) | |
8ffb8e63 S |
502 | else: |
503 | raise ExtractorError( | |
504 | 'Unsupported page type %s' % page_type, expected=True) |