2 from __future__
import unicode_literals
6 from hashlib
import sha1
7 from .common
import InfoExtractor
8 from ..compat
import compat_urllib_parse_urlencode
18 class ProSiebenSat1IE(InfoExtractor
):
19 IE_NAME
= 'prosiebensat1'
20 IE_DESC
= 'ProSiebenSat.1 Digital'
21 _VALID_URL
= r
'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|the-voice-of-germany|7tv)\.(?:de|at|ch)|ran\.de|fem\.com)/(?P<id>.+)'
25 # Tests changes introduced in https://github.com/rg3/youtube-dl/pull/6242
26 # in response to fixing https://github.com/rg3/youtube-dl/issues/6215:
27 # - malformed f4m manifest support
28 # - proper handling of URLs starting with `https?://` in 2.0 manifests
29 # - recursive child f4m manifests extraction
30 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
34 'title': 'Episode 18 - Staffel 2',
35 'description': 'md5:8733c81b702ea472e069bc48bb658fc1',
36 'upload_date': '20131231',
41 'skip_download': True,
45 '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',
49 'title': 'Lady-Umstyling für Audrina',
50 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d',
51 'upload_date': '20131014',
56 'skip_download': True,
58 'skip': 'Seems to be broken',
61 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge',
65 'title': 'Countdown für die Autowerkstatt',
66 'description': 'md5:809fc051a457b5d8666013bc40698817',
67 'upload_date': '20140223',
72 'skip_download': True,
76 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
80 'title': 'Sexy laufen in Ugg Boots',
81 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
82 'upload_date': '20140122',
87 'skip_download': True,
91 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
95 'title': 'Im Interview: Kai Wiesinger',
96 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
97 'upload_date': '20140203',
102 'skip_download': True,
106 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
110 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
111 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
112 'upload_date': '20141014',
117 'skip_download': True,
121 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
125 'title': 'Schalke: Tönnies möchte Raul zurück',
126 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
127 'upload_date': '20140226',
132 'skip_download': True,
136 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
140 'title': 'Andreas Kümmert: Rocket Man',
141 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
142 'upload_date': '20131017',
146 'skip_download': True,
150 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html',
154 'title': 'Kurztrips zum Valentinstag',
155 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.',
159 'skip_download': True,
163 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist',
166 'title': 'Episode 8 - Ganze Folge - Playlist',
167 'description': 'md5:63b8963e71f481782aeea877658dec84',
172 'url': 'http://www.7tv.de/circus-halligalli/615-best-of-circus-halligalli-ganze-folge',
176 'title': 'Best of Circus HalliGalli',
177 'description': 'md5:8849752efd90b9772c9db6fdf87fb9e9',
178 'upload_date': '20151229',
181 'skip_download': True,
187 r
'"clip_id"\s*:\s+"(\d+)"',
190 r
'clip[iI]d\s*=\s*["\'](\d
+)',
191 r"'itemImageUrl
'\s*:\s*'/dynamic
/thumbnails
/full
/\d
+/(\d
+)",
194 r'<h2 class="subtitle
" itemprop="name
">\s*(.+?)</h2>',
195 r'<header class="clearfix
">\s*<h3>(.+?)</h3>',
196 r'<!-- start video -->\s*<h1>(.+?)</h1>',
197 r'<h1 class="att
-name
">\s*(.+?)</h1>',
198 r'<header class="module_header
">\s*<h2>([^<]+)</h2>\s*</header>',
199 r'<h2 class="video
-title
" itemprop="name
">\s*(.+?)</h2>',
200 r'<div[^>]+id="veeseoTitle
"[^>]*>(.+?)</div>',
202 _DESCRIPTION_REGEXES = [
203 r'<p itemprop="description
">\s*(.+?)</p>',
204 r'<div class="videoDecription
">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
205 r'<div class="g
-plusone
" data-size="medium
"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
206 r'<p class="att
-description
">\s*(.+?)\s*</p>',
207 r'<p class="video
-description
" itemprop="description
">\s*(.+?)</p>',
208 r'<div[^>]+id="veeseoDescription
"[^>]*>(.+?)</div>',
210 _UPLOAD_DATE_REGEXES = [
211 r'<meta property="og
:published_time
" content="(.+?
)">',
212 r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration
"',
213 r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
214 r'<span style="padding
-left
: 4px
;line
-height
:20px
; color
:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
215 r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
217 _PAGE_TYPE_REGEXES
= [
218 r
'<meta name="page_type" content="([^"]+)">',
219 r
"'itemType'\s*:\s*'([^']*)'",
221 _PLAYLIST_ID_REGEXES
= [
222 r
'content[iI]d=(\d+)',
223 r
"'itemId'\s*:\s*'([^']*)'",
225 _PLAYLIST_CLIP_REGEXES
= [
226 r
'(?s)data-qvt=.+?<a href="([^"]+)"',
229 def _extract_clip(self
, url
, webpage
):
230 clip_id
= self
._html
_search
_regex
(self
._CLIPID
_REGEXES
, webpage
, 'clip id')
232 access_token
= 'prosieben'
233 client_name
= 'kolibri-2.0.19-splec4'
234 client_location
= url
236 videos_api_url
= 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse_urlencode({
237 'access_token': access_token
,
238 'client_location': client_location
,
239 'client_name': client_name
,
243 video
= self
._download
_json
(videos_api_url
, clip_id
, 'Downloading videos JSON')[0]
245 if video
.get('is_protected') is True:
246 raise ExtractorError('This video is DRM protected.', expected
=True)
248 duration
= float_or_none(video
.get('duration'))
249 source_ids
= [source
['id'] for source
in video
['sources']]
250 source_ids_str
= ','.join(map(str, source_ids
))
252 g
= '01!8d8F_)r9]4s[qeuXfP%'
254 client_id
= g
[:2] + sha1(''.join([clip_id
, g
, access_token
, client_location
, g
, client_name
])
255 .encode('utf-8')).hexdigest()
257 sources_api_url
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id
, compat_urllib_parse_urlencode({
258 'access_token': access_token
,
259 'client_id': client_id
,
260 'client_location': client_location
,
261 'client_name': client_name
,
264 sources
= self
._download
_json
(sources_api_url
, clip_id
, 'Downloading sources JSON')
265 server_id
= sources
['server_id']
267 client_id
= g
[:2] + sha1(''.join([g
, clip_id
, access_token
, server_id
,
268 client_location
, source_ids_str
, g
, client_name
])
269 .encode('utf-8')).hexdigest()
271 url_api_url
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id
, compat_urllib_parse_urlencode({
272 'access_token': access_token
,
273 'client_id': client_id
,
274 'client_location': client_location
,
275 'client_name': client_name
,
276 'server_id': server_id
,
277 'source_ids': source_ids_str
,
280 urls
= self
._download
_json
(url_api_url
, clip_id
, 'Downloading urls JSON')
282 title
= self
._html
_search
_regex
(self
._TITLE
_REGEXES
, webpage
, 'title')
283 description
= self
._html
_search
_regex
(self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False)
284 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
286 upload_date
= unified_strdate(self
._html
_search
_regex
(
287 self
._UPLOAD
_DATE
_REGEXES
, webpage
, 'upload date', default
=None))
291 urls_sources
= urls
['sources']
292 if isinstance(urls_sources
, dict):
293 urls_sources
= urls_sources
.values()
295 def fix_bitrate(bitrate
):
296 bitrate
= int_or_none(bitrate
)
299 return (bitrate
// 1000) if bitrate
% 1000 == 0 else bitrate
301 for source
in urls_sources
:
302 protocol
= source
['protocol']
303 source_url
= source
['url']
304 if protocol
== 'rtmp' or protocol
== 'rtmpe':
305 mobj
= re
.search(r
'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url
)
308 path
= mobj
.group('path')
309 mp4colon_index
= path
.rfind('mp4:')
310 app
= path
[:mp4colon_index
]
311 play_path
= path
[mp4colon_index
:]
313 'url': '%s/%s' % (mobj
.group('url'), app
),
315 'play_path': play_path
,
316 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
317 'page_url': 'http://www.prosieben.de',
318 'vbr': fix_bitrate(source
['bitrate']),
320 'format_id': '%s_%s' % (source
['cdn'], source
['bitrate']),
322 elif 'f4mgenerator' in source_url
or determine_ext(source_url
) == 'f4m':
323 formats
.extend(self
._extract
_f
4m
_formats
(source_url
, clip_id
))
327 'vbr': fix_bitrate(source
['bitrate']),
330 self
._sort
_formats
(formats
)
335 'description': description
,
336 'thumbnail': thumbnail
,
337 'upload_date': upload_date
,
338 'duration': duration
,
342 def _extract_playlist(self
, url
, webpage
):
343 playlist_id
= self
._html
_search
_regex
(
344 self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id')
345 for regex
in self
._PLAYLIST
_CLIP
_REGEXES
:
346 playlist_clips
= re
.findall(regex
, webpage
)
348 title
= self
._html
_search
_regex
(
349 self
._TITLE
_REGEXES
, webpage
, 'title')
350 description
= self
._html
_search
_regex
(
351 self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False)
354 re
.match('(.+?//.+?)/', url
).group(1) + clip_path
,
356 for clip_path
in playlist_clips
]
357 return self
.playlist_result(entries
, playlist_id
, title
, description
)
359 def _real_extract(self
, url
):
360 video_id
= self
._match
_id
(url
)
361 webpage
= self
._download
_webpage
(url
, video_id
)
362 page_type
= self
._search
_regex
(
363 self
._PAGE
_TYPE
_REGEXES
, webpage
,
364 'page type', default
='clip').lower()
365 if page_type
== 'clip':
366 return self
._extract
_clip
(url
, webpage
)
367 elif page_type
== 'playlist':
368 return self
._extract
_playlist
(url
, webpage
)