]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/prosiebensat1.py
4 from .common
import InfoExtractor
15 class ProSiebenSat1BaseIE(InfoExtractor
):
18 _SUPPORTED_PROTOCOLS
= 'dash:clear,hls:clear,progressive:clear'
19 _V4_BASE_URL
= 'https://vas-v4.p7s1video.net/4.0/get'
21 def _extract_video_info(self
, url
, clip_id
):
24 video
= self
._download
_json
(
25 'http://vas.sim-technik.de/vas/live/v2/videos',
26 clip_id
, 'Downloading videos JSON', query
={
27 'access_token': self
._TOKEN
,
28 'client_location': client_location
,
29 'client_name': self
._CLIENT
_NAME
,
33 if not self
.get_param('allow_unplayable_formats') and video
.get('is_protected') is True:
34 self
.report_drm(clip_id
)
38 raw_ct
= self
._ENCRYPTION
_KEY
+ clip_id
+ self
._IV
+ self
._ACCESS
_ID
39 protocols
= self
._download
_json
(
40 self
._V
4_BASE
_URL
+ 'protocols', clip_id
,
41 'Downloading protocols JSON',
42 headers
=self
.geo_verification_headers(), query
={
43 'access_id': self
._ACCESS
_ID
,
44 'client_token': hashlib
.sha1((raw_ct
).encode()).hexdigest(),
46 }, fatal
=False, expected_status
=(403,)) or {}
47 error
= protocols
.get('error') or {}
48 if error
.get('title') == 'Geo check failed':
49 self
.raise_geo_restricted(countries
=['AT', 'CH', 'DE'])
50 server_token
= protocols
.get('server_token')
52 urls
= (self
._download
_json
(
53 self
._V
4_BASE
_URL
+ 'urls', clip_id
, 'Downloading urls JSON', query
={
54 'access_id': self
._ACCESS
_ID
,
55 'client_token': hashlib
.sha1((raw_ct
+ server_token
+ self
._SUPPORTED
_PROTOCOLS
).encode()).hexdigest(),
56 'protocols': self
._SUPPORTED
_PROTOCOLS
,
57 'server_token': server_token
,
59 }, fatal
=False) or {}).get('urls') or {}
60 for protocol
, variant
in urls
.items():
61 source_url
= variant
.get('clear', {}).get('url')
64 if protocol
== 'dash':
65 formats
.extend(self
._extract
_mpd
_formats
(
66 source_url
, clip_id
, mpd_id
=protocol
, fatal
=False))
67 elif protocol
== 'hls':
68 formats
.extend(self
._extract
_m
3u8_formats
(
69 source_url
, clip_id
, 'mp4', 'm3u8_native',
70 m3u8_id
=protocol
, fatal
=False))
74 'format_id': protocol
,
77 source_ids
= [str(source
['id']) for source
in video
['sources']]
79 client_id
= self
._SALT
[:2] + hashlib
.sha1(''.join([clip_id
, self
._SALT
, self
._TOKEN
, client_location
, self
._SALT
, self
._CLIENT
_NAME
]).encode()).hexdigest()
81 sources
= self
._download
_json
(
82 f
'http://vas.sim-technik.de/vas/live/v2/videos/{clip_id}/sources',
83 clip_id
, 'Downloading sources JSON', query
={
84 'access_token': self
._TOKEN
,
85 'client_id': client_id
,
86 'client_location': client_location
,
87 'client_name': self
._CLIENT
_NAME
,
89 server_id
= sources
['server_id']
91 def fix_bitrate(bitrate
):
92 bitrate
= int_or_none(bitrate
)
95 return (bitrate
// 1000) if bitrate
% 1000 == 0 else bitrate
97 for source_id
in source_ids
:
98 client_id
= self
._SALT
[:2] + hashlib
.sha1(''.join([self
._SALT
, clip_id
, self
._TOKEN
, server_id
, client_location
, source_id
, self
._SALT
, self
._CLIENT
_NAME
]).encode()).hexdigest()
99 urls
= self
._download
_json
(
100 f
'http://vas.sim-technik.de/vas/live/v2/videos/{clip_id}/sources/url',
101 clip_id
, 'Downloading urls JSON', fatal
=False, query
={
102 'access_token': self
._TOKEN
,
103 'client_id': client_id
,
104 'client_location': client_location
,
105 'client_name': self
._CLIENT
_NAME
,
106 'server_id': server_id
,
107 'source_ids': source_id
,
111 if urls
.get('status_code') != 0:
112 raise ExtractorError('This video is unavailable', expected
=True)
113 urls_sources
= urls
['sources']
114 if isinstance(urls_sources
, dict):
115 urls_sources
= urls_sources
.values()
116 for source
in urls_sources
:
117 source_url
= source
.get('url')
120 protocol
= source
.get('protocol')
121 mimetype
= source
.get('mimetype')
122 if mimetype
== 'application/f4m+xml' or 'f4mgenerator' in source_url
or determine_ext(source_url
) == 'f4m':
123 formats
.extend(self
._extract
_f
4m
_formats
(
124 source_url
, clip_id
, f4m_id
='hds', fatal
=False))
125 elif mimetype
== 'application/x-mpegURL':
126 formats
.extend(self
._extract
_m
3u8_formats
(
127 source_url
, clip_id
, 'mp4', 'm3u8_native',
128 m3u8_id
='hls', fatal
=False))
129 elif mimetype
== 'application/dash+xml':
130 formats
.extend(self
._extract
_mpd
_formats
(
131 source_url
, clip_id
, mpd_id
='dash', fatal
=False))
133 tbr
= fix_bitrate(source
['bitrate'])
134 if protocol
in ('rtmp', 'rtmpe'):
135 mobj
= re
.search(r
'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url
)
138 path
= mobj
.group('path')
139 mp4colon_index
= path
.rfind('mp4:')
140 app
= path
[:mp4colon_index
]
141 play_path
= path
[mp4colon_index
:]
143 'url': '{}/{}'.format(mobj
.group('url'), app
),
145 'play_path': play_path
,
146 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
147 'page_url': 'http://www.prosieben.de',
150 'format_id': 'rtmp{}'.format(f'-{tbr}' if tbr
else ''),
156 'format_id': 'http{}'.format(f'-{tbr}' if tbr
else ''),
160 'duration': float_or_none(video
.get('duration')),
165 class ProSiebenSat1IE(ProSiebenSat1BaseIE
):
166 IE_NAME
= 'prosiebensat1'
167 IE_DESC
= 'ProSiebenSat.1 Digital'
168 _VALID_URL
= r
'''(?x)
174 prosieben(?:maxx)?|sixx|sat1(?:gold)?|kabeleins(?:doku)?|the-voice-of-germany|advopedia
176 ran\.de|fem\.com|advopedia\.de|galileo\.tv/video
183 # Tests changes introduced in https://github.com/ytdl-org/youtube-dl/pull/6242
184 # in response to fixing https://github.com/ytdl-org/youtube-dl/issues/6215:
185 # - malformed f4m manifest support
186 # - proper handling of URLs starting with `https?://` in 2.0 manifests
187 # - recursive child f4m manifests extraction
188 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
192 'title': 'CIRCUS HALLIGALLI - Episode 18 - Staffel 2',
193 'description': 'md5:8733c81b702ea472e069bc48bb658fc1',
194 'upload_date': '20131231',
196 'series': 'CIRCUS HALLIGALLI',
198 'episode': 'Episode 18 - Staffel 2',
199 'episode_number': 18,
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',
207 'title': 'Lady-Umstyling für Audrina',
208 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d',
209 'upload_date': '20131014',
214 'skip_download': True,
216 'skip': 'Seems to be broken',
219 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge',
223 'title': 'Countdown für die Autowerkstatt',
224 'description': 'md5:809fc051a457b5d8666013bc40698817',
225 'upload_date': '20140223',
230 'skip_download': True,
232 'skip': 'This video is unavailable',
235 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
239 'title': 'Sexy laufen in Ugg Boots',
240 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
241 'upload_date': '20140122',
246 'skip_download': True,
248 'skip': 'This video is unavailable',
251 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
255 'title': 'Im Interview: Kai Wiesinger',
256 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
257 'upload_date': '20140203',
262 'skip_download': True,
264 'skip': 'This video is unavailable',
267 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
271 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
272 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
273 'upload_date': '20141014',
278 'skip_download': True,
280 'skip': 'This video is unavailable',
283 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
287 'title': 'Schalke: Tönnies möchte Raul zurück',
288 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
289 'upload_date': '20140226',
294 'skip_download': True,
296 'skip': 'This video is unavailable',
299 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
303 'title': 'The Voice of Germany - Andreas Kümmert: Rocket Man',
304 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
305 'timestamp': 1382041620,
306 'upload_date': '20131017',
310 'skip_download': True,
314 'url': 'http://www.fem.com/videos/beauty-lifestyle/kurztrips-zum-valentinstag',
318 'title': 'Kurztrips zum Valentinstag',
319 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.',
323 'skip_download': True,
327 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist',
330 'title': 'Episode 8 - Ganze Folge - Playlist',
331 'description': 'md5:63b8963e71f481782aeea877658dec84',
334 'skip': 'This video is unavailable',
337 # title in <h2 class="subtitle">
338 'url': 'http://www.prosieben.de/stars/oscar-award/videos/jetzt-erst-enthuellt-das-geheimnis-von-emma-stones-oscar-robe-clip',
342 'title': 'Jetzt erst enthüllt: Das Geheimnis von Emma Stones Oscar-Robe',
343 'description': 'md5:e5ace2bc43fadf7b63adc6187e9450b9',
344 'upload_date': '20170302',
347 'skip_download': True,
349 'skip': 'geo restricted to Germany',
352 # geo restricted to Germany
353 'url': 'http://www.kabeleinsdoku.de/tv/mayday-alarm-im-cockpit/video/102-notlandung-im-hudson-river-ganze-folge',
354 'only_matching': True,
357 # geo restricted to Germany
358 'url': 'http://www.sat1gold.de/tv/edel-starck/video/11-staffel-1-episode-1-partner-wider-willen-ganze-folge',
359 'only_matching': True,
362 # geo restricted to Germany
363 'url': 'https://www.galileo.tv/video/diese-emojis-werden-oft-missverstanden',
364 'only_matching': True,
367 'url': 'http://www.sat1gold.de/tv/edel-starck/playlist/die-gesamte-1-staffel',
368 'only_matching': True,
371 'url': 'http://www.advopedia.de/videos/lenssen-klaert-auf/lenssen-klaert-auf-folge-8-staffel-3-feiertage-und-freie-tage',
372 'only_matching': True,
377 _SALT
= '01!8d8F_)r9]4s[qeuXfP%'
378 _CLIENT_NAME
= 'kolibri-2.0.19-splec4'
380 _ACCESS_ID
= 'x_prosiebenmaxx-de'
381 _ENCRYPTION_KEY
= 'Eeyeey9oquahthainoofashoyoikosag'
382 _IV
= 'Aeluchoc6aevechuipiexeeboowedaok'
385 r
'"clip_id"\s*:\s+"(\d+)"',
388 r
'clip[iI][dD]\s*=\s*["\'](\d
+)',
389 r"'itemImageUrl
'\s*:\s*'/dynamic
/thumbnails
/full
/\d
+/(\d
+)",
390 r'proMamsId"\s*:\s*"(\d+)',
391 r'proMamsId"\s
*:\s
*"(\d+)',
394 r'<h2 class="subtitle
" itemprop="name
">\s*(.+?)</h2>',
395 r'<header class="clearfix
">\s*<h3>(.+?)</h3>',
396 r'<!-- start video -->\s*<h1>(.+?)</h1>',
397 r'<h1 class="att
-name
">\s*(.+?)</h1>',
398 r'<header class="module_header
">\s*<h2>([^<]+)</h2>\s*</header>',
399 r'<h2 class="video
-title
" itemprop="name
">\s*(.+?)</h2>',
400 r'<div[^>]+id="veeseoTitle
"[^>]*>(.+?)</div>',
401 r'<h2[^>]+class="subtitle
"[^>]*>([^<]+)</h2>',
403 _DESCRIPTION_REGEXES = [
404 r'<p itemprop="description
">\s*(.+?)</p>',
405 r'<div class="videoDecription
">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
406 r'<div class="g
-plusone
" data-size="medium
"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
407 r'<p class="att
-description
">\s*(.+?)\s*</p>',
408 r'<p class="video
-description
" itemprop="description
">\s*(.+?)</p>',
409 r'<div[^>]+id="veeseoDescription
"[^>]*>(.+?)</div>',
411 _UPLOAD_DATE_REGEXES = [
412 r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration
"',
413 r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
414 r'<span style="padding
-left
: 4px
;line
-height
:20px
; color
:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
415 r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
417 _PAGE_TYPE_REGEXES
= [
418 r
'<meta name="page_type" content="([^"]+)">',
419 r
"'itemType'\s*:\s*'([^']*)'",
421 _PLAYLIST_ID_REGEXES
= [
422 r
'content[iI]d=(\d+)',
423 r
"'itemId'\s*:\s*'([^']*)'",
425 _PLAYLIST_CLIP_REGEXES
= [
426 r
'(?s)data-qvt=.+?<a href="([^"]+)"',
429 def _extract_clip(self
, url
, webpage
):
430 clip_id
= self
._html
_search
_regex
(
431 self
._CLIPID
_REGEXES
, webpage
, 'clip id')
432 title
= self
._html
_search
_regex
(
433 self
._TITLE
_REGEXES
, webpage
, 'title',
434 default
=None) or self
._og
_search
_title
(webpage
)
435 info
= self
._extract
_video
_info
(url
, clip_id
)
436 description
= self
._html
_search
_regex
(
437 self
._DESCRIPTION
_REGEXES
, webpage
, 'description', default
=None)
438 if description
is None:
439 description
= self
._og
_search
_description
(webpage
)
440 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
441 upload_date
= unified_strdate(
442 self
._html
_search
_meta
('og:published_time', webpage
,
443 'upload date', default
=None)
444 or self
._html
_search
_regex
(self
._UPLOAD
_DATE
_REGEXES
,
445 webpage
, 'upload date', default
=None))
447 json_ld
= self
._search
_json
_ld
(webpage
, clip_id
, default
={})
449 return merge_dicts(info
, {
452 'description': description
,
453 'thumbnail': thumbnail
,
454 'upload_date': upload_date
,
457 def _extract_playlist(self
, url
, webpage
):
458 playlist_id
= self
._html
_search
_regex
(
459 self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id')
460 playlist
= self
._parse
_json
(
462 r
'var\s+contentResources\s*=\s*(\[.+?\]);\s*</script',
463 webpage
, 'playlist'),
466 for item
in playlist
:
467 clip_id
= item
.get('id') or item
.get('upc')
470 info
= self
._extract
_video
_info
(url
, clip_id
)
473 'title': item
.get('title') or item
.get('teaser', {}).get('headline'),
474 'description': item
.get('teaser', {}).get('description'),
475 'thumbnail': item
.get('poster'),
476 'duration': float_or_none(item
.get('duration')),
477 'series': item
.get('tvShowTitle'),
478 'uploader': item
.get('broadcastPublisher'),
481 return self
.playlist_result(entries
, playlist_id
)
483 def _real_extract(self
, url
):
484 video_id
= self
._match
_id
(url
)
485 webpage
= self
._download
_webpage
(url
, video_id
)
486 page_type
= self
._search
_regex
(
487 self
._PAGE
_TYPE
_REGEXES
, webpage
,
488 'page type', default
='clip').lower()
489 if page_type
== 'clip':
490 return self
._extract
_clip
(url
, webpage
)
491 elif page_type
== 'playlist':
492 return self
._extract
_playlist
(url
, webpage
)
494 raise ExtractorError(
495 f
'Unsupported page type {page_type}', expected
=True)