]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/prosiebensat1.py
c6eee3b72a6e428012644ee7c10caad9be78fa86
2 from __future__
import unicode_literals
6 from hashlib
import sha1
7 from .common
import InfoExtractor
8 from ..compat
import compat_str
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,
74 'skip': 'This video is unavailable',
77 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
81 'title': 'Sexy laufen in Ugg Boots',
82 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
83 'upload_date': '20140122',
88 'skip_download': True,
90 'skip': 'This video is unavailable',
93 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
97 'title': 'Im Interview: Kai Wiesinger',
98 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
99 'upload_date': '20140203',
104 'skip_download': True,
106 'skip': 'This video is unavailable',
109 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
113 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
114 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
115 'upload_date': '20141014',
120 'skip_download': True,
122 'skip': 'This video is unavailable',
125 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
129 'title': 'Schalke: Tönnies möchte Raul zurück',
130 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
131 'upload_date': '20140226',
136 'skip_download': True,
138 'skip': 'This video is unavailable',
141 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
145 'title': 'Andreas Kümmert: Rocket Man',
146 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
147 'upload_date': '20131017',
151 'skip_download': True,
155 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html',
159 'title': 'Kurztrips zum Valentinstag',
160 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.',
164 'skip_download': True,
168 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist',
171 'title': 'Episode 8 - Ganze Folge - Playlist',
172 'description': 'md5:63b8963e71f481782aeea877658dec84',
177 'url': 'http://www.7tv.de/circus-halligalli/615-best-of-circus-halligalli-ganze-folge',
181 'title': 'Best of Circus HalliGalli',
182 'description': 'md5:8849752efd90b9772c9db6fdf87fb9e9',
183 'upload_date': '20151229',
186 'skip_download': True,
192 r
'"clip_id"\s*:\s+"(\d+)"',
195 r
'clip[iI]d\s*=\s*["\'](\d
+)',
196 r"'itemImageUrl
'\s*:\s*'/dynamic
/thumbnails
/full
/\d
+/(\d
+)",
199 r'<h2 class="subtitle
" itemprop="name
">\s*(.+?)</h2>',
200 r'<header class="clearfix
">\s*<h3>(.+?)</h3>',
201 r'<!-- start video -->\s*<h1>(.+?)</h1>',
202 r'<h1 class="att
-name
">\s*(.+?)</h1>',
203 r'<header class="module_header
">\s*<h2>([^<]+)</h2>\s*</header>',
204 r'<h2 class="video
-title
" itemprop="name
">\s*(.+?)</h2>',
205 r'<div[^>]+id="veeseoTitle
"[^>]*>(.+?)</div>',
207 _DESCRIPTION_REGEXES = [
208 r'<p itemprop="description
">\s*(.+?)</p>',
209 r'<div class="videoDecription
">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
210 r'<div class="g
-plusone
" data-size="medium
"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
211 r'<p class="att
-description
">\s*(.+?)\s*</p>',
212 r'<p class="video
-description
" itemprop="description
">\s*(.+?)</p>',
213 r'<div[^>]+id="veeseoDescription
"[^>]*>(.+?)</div>',
215 _UPLOAD_DATE_REGEXES = [
216 r'<meta property="og
:published_time
" content="(.+?
)">',
217 r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration
"',
218 r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
219 r'<span style="padding
-left
: 4px
;line
-height
:20px
; color
:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
220 r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
222 _PAGE_TYPE_REGEXES
= [
223 r
'<meta name="page_type" content="([^"]+)">',
224 r
"'itemType'\s*:\s*'([^']*)'",
226 _PLAYLIST_ID_REGEXES
= [
227 r
'content[iI]d=(\d+)',
228 r
"'itemId'\s*:\s*'([^']*)'",
230 _PLAYLIST_CLIP_REGEXES
= [
231 r
'(?s)data-qvt=.+?<a href="([^"]+)"',
234 def _extract_clip(self
, url
, webpage
):
235 clip_id
= self
._html
_search
_regex
(
236 self
._CLIPID
_REGEXES
, webpage
, 'clip id')
238 access_token
= 'prosieben'
239 client_name
= 'kolibri-2.0.19-splec4'
240 client_location
= url
242 video
= self
._download
_json
(
243 'http://vas.sim-technik.de/vas/live/v2/videos',
244 clip_id
, 'Downloading videos JSON', query
={
245 'access_token': access_token
,
246 'client_location': client_location
,
247 'client_name': client_name
,
251 if video
.get('is_protected') is True:
252 raise ExtractorError('This video is DRM protected.', expected
=True)
254 duration
= float_or_none(video
.get('duration'))
255 source_ids
= [compat_str(source
['id']) for source
in video
['sources']]
257 g
= '01!8d8F_)r9]4s[qeuXfP%'
258 client_id
= g
[:2] + sha1(''.join([clip_id
, g
, access_token
, client_location
, g
, client_name
]).encode('utf-8')).hexdigest()
260 sources
= self
._download
_json
(
261 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources' % clip_id
,
262 clip_id
, 'Downloading sources JSON', query
={
263 'access_token': access_token
,
264 'client_id': client_id
,
265 'client_location': client_location
,
266 'client_name': client_name
,
268 server_id
= sources
['server_id']
270 title
= self
._html
_search
_regex
(self
._TITLE
_REGEXES
, webpage
, 'title')
272 def fix_bitrate(bitrate
):
273 bitrate
= int_or_none(bitrate
)
276 return (bitrate
// 1000) if bitrate
% 1000 == 0 else bitrate
279 for source_id
in source_ids
:
280 client_id
= g
[:2] + sha1(''.join([g
, clip_id
, access_token
, server_id
, client_location
, source_id
, g
, client_name
]).encode('utf-8')).hexdigest()
281 urls
= self
._download
_json
(
282 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url' % clip_id
,
283 clip_id
, 'Downloading urls JSON', fatal
=False, query
={
284 'access_token': access_token
,
285 'client_id': client_id
,
286 'client_location': client_location
,
287 'client_name': client_name
,
288 'server_id': server_id
,
289 'source_ids': source_id
,
293 if urls
.get('status_code') != 0:
294 raise ExtractorError('This video is unavailable', expected
=True)
295 urls_sources
= urls
['sources']
296 if isinstance(urls_sources
, dict):
297 urls_sources
= urls_sources
.values()
298 for source
in urls_sources
:
299 source_url
= source
.get('url')
302 protocol
= source
.get('protocol')
303 mimetype
= source
.get('mimetype')
304 if mimetype
== 'application/f4m+xml' or 'f4mgenerator' in source_url
or determine_ext(source_url
) == 'f4m':
305 formats
.extend(self
._extract
_f
4m
_formats
(
306 source_url
, clip_id
, f4m_id
='hds', fatal
=False))
307 elif mimetype
== 'application/x-mpegURL':
308 formats
.extend(self
._extract
_m
3u8_formats
(
309 source_url
, clip_id
, 'mp4', 'm3u8_native',
310 m3u8_id
='hls', fatal
=False))
312 tbr
= fix_bitrate(source
['bitrate'])
313 if protocol
in ('rtmp', 'rtmpe'):
314 mobj
= re
.search(r
'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url
)
317 path
= mobj
.group('path')
318 mp4colon_index
= path
.rfind('mp4:')
319 app
= path
[:mp4colon_index
]
320 play_path
= path
[mp4colon_index
:]
322 'url': '%s/%s' % (mobj
.group('url'), app
),
324 'play_path': play_path
,
325 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
326 'page_url': 'http://www.prosieben.de',
329 'format_id': 'rtmp%s' % ('-%d' % tbr
if tbr
else ''),
335 'format_id': 'http%s' % ('-%d' % tbr
if tbr
else ''),
337 self
._sort
_formats
(formats
)
339 description
= self
._html
_search
_regex
(
340 self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False)
341 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
342 upload_date
= unified_strdate(self
._html
_search
_regex
(
343 self
._UPLOAD
_DATE
_REGEXES
, webpage
, 'upload date', default
=None))
348 'description': description
,
349 'thumbnail': thumbnail
,
350 'upload_date': upload_date
,
351 'duration': duration
,
355 def _extract_playlist(self
, url
, webpage
):
356 playlist_id
= self
._html
_search
_regex
(
357 self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id')
358 for regex
in self
._PLAYLIST
_CLIP
_REGEXES
:
359 playlist_clips
= re
.findall(regex
, webpage
)
361 title
= self
._html
_search
_regex
(
362 self
._TITLE
_REGEXES
, webpage
, 'title')
363 description
= self
._html
_search
_regex
(
364 self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False)
367 re
.match('(.+?//.+?)/', url
).group(1) + clip_path
,
369 for clip_path
in playlist_clips
]
370 return self
.playlist_result(entries
, playlist_id
, title
, description
)
372 def _real_extract(self
, url
):
373 video_id
= self
._match
_id
(url
)
374 webpage
= self
._download
_webpage
(url
, video_id
)
375 page_type
= self
._search
_regex
(
376 self
._PAGE
_TYPE
_REGEXES
, webpage
,
377 'page type', default
='clip').lower()
378 if page_type
== 'clip':
379 return self
._extract
_clip
(url
, webpage
)
380 elif page_type
== 'playlist':
381 return self
._extract
_playlist
(url
, webpage
)