4 from .common
import InfoExtractor
16 class ProSiebenSat1BaseIE(InfoExtractor
):
19 _SUPPORTED_PROTOCOLS
= 'dash:clear,hls:clear,progressive:clear'
20 _V4_BASE_URL
= 'https://vas-v4.p7s1video.net/4.0/get'
22 def _extract_video_info(self
, url
, clip_id
):
25 video
= self
._download
_json
(
26 'http://vas.sim-technik.de/vas/live/v2/videos',
27 clip_id
, 'Downloading videos JSON', query
={
28 'access_token': self
._TOKEN
,
29 'client_location': client_location
,
30 'client_name': self
._CLIENT
_NAME
,
34 if not self
.get_param('allow_unplayable_formats') and video
.get('is_protected') is True:
35 self
.report_drm(clip_id
)
39 raw_ct
= self
._ENCRYPTION
_KEY
+ clip_id
+ self
._IV
+ self
._ACCESS
_ID
40 protocols
= self
._download
_json
(
41 self
._V
4_BASE
_URL
+ 'protocols', clip_id
,
42 'Downloading protocols JSON',
43 headers
=self
.geo_verification_headers(), query
={
44 'access_id': self
._ACCESS
_ID
,
45 'client_token': hashlib
.sha1((raw_ct
).encode()).hexdigest(),
47 }, fatal
=False, expected_status
=(403,)) or {}
48 error
= protocols
.get('error') or {}
49 if error
.get('title') == 'Geo check failed':
50 self
.raise_geo_restricted(countries
=['AT', 'CH', 'DE'])
51 server_token
= protocols
.get('server_token')
53 urls
= (self
._download
_json
(
54 self
._V
4_BASE
_URL
+ 'urls', clip_id
, 'Downloading urls JSON', query
={
55 'access_id': self
._ACCESS
_ID
,
56 'client_token': hashlib
.sha1((raw_ct
+ server_token
+ self
._SUPPORTED
_PROTOCOLS
).encode()).hexdigest(),
57 'protocols': self
._SUPPORTED
_PROTOCOLS
,
58 'server_token': server_token
,
60 }, fatal
=False) or {}).get('urls') or {}
61 for protocol
, variant
in urls
.items():
62 source_url
= variant
.get('clear', {}).get('url')
65 if protocol
== 'dash':
66 formats
.extend(self
._extract
_mpd
_formats
(
67 source_url
, clip_id
, mpd_id
=protocol
, fatal
=False))
68 elif protocol
== 'hls':
69 formats
.extend(self
._extract
_m
3u8_formats
(
70 source_url
, clip_id
, 'mp4', 'm3u8_native',
71 m3u8_id
=protocol
, fatal
=False))
75 'format_id': protocol
,
78 source_ids
= [str(source
['id']) for source
in video
['sources']]
80 client_id
= self
._SALT
[:2] + hashlib
.sha1(''.join([clip_id
, self
._SALT
, self
._TOKEN
, client_location
, self
._SALT
, self
._CLIENT
_NAME
]).encode()).hexdigest()
82 sources
= self
._download
_json
(
83 f
'http://vas.sim-technik.de/vas/live/v2/videos/{clip_id}/sources',
84 clip_id
, 'Downloading sources JSON', query
={
85 'access_token': self
._TOKEN
,
86 'client_id': client_id
,
87 'client_location': client_location
,
88 'client_name': self
._CLIENT
_NAME
,
90 server_id
= sources
['server_id']
92 def fix_bitrate(bitrate
):
93 bitrate
= int_or_none(bitrate
)
96 return (bitrate
// 1000) if bitrate
% 1000 == 0 else bitrate
98 for source_id
in source_ids
:
99 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()
100 urls
= self
._download
_json
(
101 f
'http://vas.sim-technik.de/vas/live/v2/videos/{clip_id}/sources/url',
102 clip_id
, 'Downloading urls JSON', fatal
=False, query
={
103 'access_token': self
._TOKEN
,
104 'client_id': client_id
,
105 'client_location': client_location
,
106 'client_name': self
._CLIENT
_NAME
,
107 'server_id': server_id
,
108 'source_ids': source_id
,
112 if urls
.get('status_code') != 0:
113 raise ExtractorError('This video is unavailable', expected
=True)
114 urls_sources
= urls
['sources']
115 if isinstance(urls_sources
, dict):
116 urls_sources
= urls_sources
.values()
117 for source
in urls_sources
:
118 source_url
= source
.get('url')
121 protocol
= source
.get('protocol')
122 mimetype
= source
.get('mimetype')
123 if mimetype
== 'application/f4m+xml' or 'f4mgenerator' in source_url
or determine_ext(source_url
) == 'f4m':
124 formats
.extend(self
._extract
_f
4m
_formats
(
125 source_url
, clip_id
, f4m_id
='hds', fatal
=False))
126 elif mimetype
== 'application/x-mpegURL':
127 formats
.extend(self
._extract
_m
3u8_formats
(
128 source_url
, clip_id
, 'mp4', 'm3u8_native',
129 m3u8_id
='hls', fatal
=False))
130 elif mimetype
== 'application/dash+xml':
131 formats
.extend(self
._extract
_mpd
_formats
(
132 source_url
, clip_id
, mpd_id
='dash', fatal
=False))
134 tbr
= fix_bitrate(source
['bitrate'])
135 if protocol
in ('rtmp', 'rtmpe'):
136 mobj
= re
.search(r
'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url
)
139 path
= mobj
.group('path')
140 mp4colon_index
= path
.rfind('mp4:')
141 app
= path
[:mp4colon_index
]
142 play_path
= path
[mp4colon_index
:]
144 'url': '{}/{}'.format(mobj
.group('url'), app
),
146 'play_path': play_path
,
147 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
148 'page_url': 'http://www.prosieben.de',
151 'format_id': join_nonempty('rtmp', tbr
),
157 'format_id': join_nonempty('http', tbr
),
161 'duration': float_or_none(video
.get('duration')),
166 class ProSiebenSat1IE(ProSiebenSat1BaseIE
):
167 IE_NAME
= 'prosiebensat1'
168 IE_DESC
= 'ProSiebenSat.1 Digital'
169 _VALID_URL
= r
'''(?x)
175 prosieben(?:maxx)?|sixx|sat1(?:gold)?|kabeleins(?:doku)?|the-voice-of-germany|advopedia
177 ran\.de|fem\.com|advopedia\.de|galileo\.tv/video
184 # Tests changes introduced in https://github.com/ytdl-org/youtube-dl/pull/6242
185 # in response to fixing https://github.com/ytdl-org/youtube-dl/issues/6215:
186 # - malformed f4m manifest support
187 # - proper handling of URLs starting with `https?://` in 2.0 manifests
188 # - recursive child f4m manifests extraction
189 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
193 'title': 'CIRCUS HALLIGALLI - Episode 18 - Staffel 2',
194 'description': 'md5:8733c81b702ea472e069bc48bb658fc1',
195 'upload_date': '20131231',
197 'series': 'CIRCUS HALLIGALLI',
199 'episode': 'Episode 18 - Staffel 2',
200 'episode_number': 18,
204 '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',
208 'title': 'Lady-Umstyling für Audrina',
209 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d',
210 'upload_date': '20131014',
215 'skip_download': True,
217 'skip': 'Seems to be broken',
220 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge',
224 'title': 'Countdown für die Autowerkstatt',
225 'description': 'md5:809fc051a457b5d8666013bc40698817',
226 'upload_date': '20140223',
231 'skip_download': True,
233 'skip': 'This video is unavailable',
236 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
240 'title': 'Sexy laufen in Ugg Boots',
241 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
242 'upload_date': '20140122',
247 'skip_download': True,
249 'skip': 'This video is unavailable',
252 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
256 'title': 'Im Interview: Kai Wiesinger',
257 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
258 'upload_date': '20140203',
263 'skip_download': True,
265 'skip': 'This video is unavailable',
268 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
272 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
273 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
274 'upload_date': '20141014',
279 'skip_download': True,
281 'skip': 'This video is unavailable',
284 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
288 'title': 'Schalke: Tönnies möchte Raul zurück',
289 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
290 'upload_date': '20140226',
295 'skip_download': True,
297 'skip': 'This video is unavailable',
300 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
304 'title': 'The Voice of Germany - Andreas Kümmert: Rocket Man',
305 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
306 'timestamp': 1382041620,
307 'upload_date': '20131017',
311 'skip_download': True,
315 'url': 'http://www.fem.com/videos/beauty-lifestyle/kurztrips-zum-valentinstag',
319 'title': 'Kurztrips zum Valentinstag',
320 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.',
324 'skip_download': True,
328 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist',
331 'title': 'Episode 8 - Ganze Folge - Playlist',
332 'description': 'md5:63b8963e71f481782aeea877658dec84',
335 'skip': 'This video is unavailable',
338 # title in <h2 class="subtitle">
339 'url': 'http://www.prosieben.de/stars/oscar-award/videos/jetzt-erst-enthuellt-das-geheimnis-von-emma-stones-oscar-robe-clip',
343 'title': 'Jetzt erst enthüllt: Das Geheimnis von Emma Stones Oscar-Robe',
344 'description': 'md5:e5ace2bc43fadf7b63adc6187e9450b9',
345 'upload_date': '20170302',
348 'skip_download': True,
350 'skip': 'geo restricted to Germany',
353 # geo restricted to Germany
354 'url': 'http://www.kabeleinsdoku.de/tv/mayday-alarm-im-cockpit/video/102-notlandung-im-hudson-river-ganze-folge',
355 'only_matching': True,
358 # geo restricted to Germany
359 'url': 'http://www.sat1gold.de/tv/edel-starck/video/11-staffel-1-episode-1-partner-wider-willen-ganze-folge',
360 'only_matching': True,
363 # geo restricted to Germany
364 'url': 'https://www.galileo.tv/video/diese-emojis-werden-oft-missverstanden',
365 'only_matching': True,
368 'url': 'http://www.sat1gold.de/tv/edel-starck/playlist/die-gesamte-1-staffel',
369 'only_matching': True,
372 'url': 'http://www.advopedia.de/videos/lenssen-klaert-auf/lenssen-klaert-auf-folge-8-staffel-3-feiertage-und-freie-tage',
373 'only_matching': True,
378 _SALT
= '01!8d8F_)r9]4s[qeuXfP%'
379 _CLIENT_NAME
= 'kolibri-2.0.19-splec4'
381 _ACCESS_ID
= 'x_prosiebenmaxx-de'
382 _ENCRYPTION_KEY
= 'Eeyeey9oquahthainoofashoyoikosag'
383 _IV
= 'Aeluchoc6aevechuipiexeeboowedaok'
386 r
'"clip_id"\s*:\s+"(\d+)"',
389 r
'clip[iI][dD]\s*=\s*["\'](\d
+)',
390 r"'itemImageUrl
'\s*:\s*'/dynamic
/thumbnails
/full
/\d
+/(\d
+)",
391 r'proMamsId"\s*:\s*"(\d+)',
392 r'proMamsId"\s
*:\s
*"(\d+)',
395 r'<h2 class="subtitle
" itemprop="name
">\s*(.+?)</h2>',
396 r'<header class="clearfix
">\s*<h3>(.+?)</h3>',
397 r'<!-- start video -->\s*<h1>(.+?)</h1>',
398 r'<h1 class="att
-name
">\s*(.+?)</h1>',
399 r'<header class="module_header
">\s*<h2>([^<]+)</h2>\s*</header>',
400 r'<h2 class="video
-title
" itemprop="name
">\s*(.+?)</h2>',
401 r'<div[^>]+id="veeseoTitle
"[^>]*>(.+?)</div>',
402 r'<h2[^>]+class="subtitle
"[^>]*>([^<]+)</h2>',
404 _DESCRIPTION_REGEXES = [
405 r'<p itemprop="description
">\s*(.+?)</p>',
406 r'<div class="videoDecription
">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
407 r'<div class="g
-plusone
" data-size="medium
"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
408 r'<p class="att
-description
">\s*(.+?)\s*</p>',
409 r'<p class="video
-description
" itemprop="description
">\s*(.+?)</p>',
410 r'<div[^>]+id="veeseoDescription
"[^>]*>(.+?)</div>',
412 _UPLOAD_DATE_REGEXES = [
413 r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration
"',
414 r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
415 r'<span style="padding
-left
: 4px
;line
-height
:20px
; color
:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
416 r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
418 _PAGE_TYPE_REGEXES
= [
419 r
'<meta name="page_type" content="([^"]+)">',
420 r
"'itemType'\s*:\s*'([^']*)'",
422 _PLAYLIST_ID_REGEXES
= [
423 r
'content[iI]d=(\d+)',
424 r
"'itemId'\s*:\s*'([^']*)'",
426 _PLAYLIST_CLIP_REGEXES
= [
427 r
'(?s)data-qvt=.+?<a href="([^"]+)"',
430 def _extract_clip(self
, url
, webpage
):
431 clip_id
= self
._html
_search
_regex
(
432 self
._CLIPID
_REGEXES
, webpage
, 'clip id')
433 title
= self
._html
_search
_regex
(
434 self
._TITLE
_REGEXES
, webpage
, 'title',
435 default
=None) or self
._og
_search
_title
(webpage
)
436 info
= self
._extract
_video
_info
(url
, clip_id
)
437 description
= self
._html
_search
_regex
(
438 self
._DESCRIPTION
_REGEXES
, webpage
, 'description', default
=None)
439 if description
is None:
440 description
= self
._og
_search
_description
(webpage
)
441 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
442 upload_date
= unified_strdate(
443 self
._html
_search
_meta
('og:published_time', webpage
,
444 'upload date', default
=None)
445 or self
._html
_search
_regex
(self
._UPLOAD
_DATE
_REGEXES
,
446 webpage
, 'upload date', default
=None))
448 json_ld
= self
._search
_json
_ld
(webpage
, clip_id
, default
={})
450 return merge_dicts(info
, {
453 'description': description
,
454 'thumbnail': thumbnail
,
455 'upload_date': upload_date
,
458 def _extract_playlist(self
, url
, webpage
):
459 playlist_id
= self
._html
_search
_regex
(
460 self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id')
461 playlist
= self
._parse
_json
(
463 r
'var\s+contentResources\s*=\s*(\[.+?\]);\s*</script',
464 webpage
, 'playlist'),
467 for item
in playlist
:
468 clip_id
= item
.get('id') or item
.get('upc')
471 info
= self
._extract
_video
_info
(url
, clip_id
)
474 'title': item
.get('title') or item
.get('teaser', {}).get('headline'),
475 'description': item
.get('teaser', {}).get('description'),
476 'thumbnail': item
.get('poster'),
477 'duration': float_or_none(item
.get('duration')),
478 'series': item
.get('tvShowTitle'),
479 'uploader': item
.get('broadcastPublisher'),
482 return self
.playlist_result(entries
, playlist_id
)
484 def _real_extract(self
, url
):
485 video_id
= self
._match
_id
(url
)
486 webpage
= self
._download
_webpage
(url
, video_id
)
487 page_type
= self
._search
_regex
(
488 self
._PAGE
_TYPE
_REGEXES
, webpage
,
489 'page type', default
='clip').lower()
490 if page_type
== 'clip':
491 return self
._extract
_clip
(url
, webpage
)
492 elif page_type
== 'playlist':
493 return self
._extract
_playlist
(url
, webpage
)
495 raise ExtractorError(
496 f
'Unsupported page type {page_type}', expected
=True)