]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/prosiebensat1.py
7cc7996642cae1de1ca2a585391d167025b92162
2 from __future__
import unicode_literals
6 from hashlib
import sha1
7 from .common
import InfoExtractor
17 class ProSiebenSat1IE(InfoExtractor
):
18 IE_NAME
= 'prosiebensat1'
19 IE_DESC
= 'ProSiebenSat.1 Digital'
20 _VALID_URL
= r
'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|ran|the-voice-of-germany)\.de|fem\.com)/(?P<id>.+)'
24 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
28 'title': 'Episode 18 - Staffel 2',
29 'description': 'md5:8733c81b702ea472e069bc48bb658fc1',
30 'upload_date': '20131231',
35 'skip_download': True,
39 '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',
43 'title': 'Lady-Umstyling für Audrina',
44 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d',
45 'upload_date': '20131014',
50 'skip_download': True,
52 'skip': 'Seems to be broken',
55 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge',
59 'title': 'Countdown für die Autowerkstatt',
60 'description': 'md5:809fc051a457b5d8666013bc40698817',
61 'upload_date': '20140223',
66 'skip_download': True,
70 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
74 'title': 'Sexy laufen in Ugg Boots',
75 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
76 'upload_date': '20140122',
81 'skip_download': True,
85 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
89 'title': 'Im Interview: Kai Wiesinger',
90 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
91 'upload_date': '20140203',
96 'skip_download': True,
100 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
104 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
105 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
106 'upload_date': '20141014',
111 'skip_download': True,
115 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
119 'title': 'Schalke: Tönnies möchte Raul zurück',
120 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
121 'upload_date': '20140226',
126 'skip_download': True,
130 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
134 'title': 'Andreas Kümmert: Rocket Man',
135 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
136 'upload_date': '20131017',
141 'skip_download': True,
145 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html',
149 'title': 'Kurztrips zum Valentinstag',
150 'description': 'Romantischer Kurztrip zum Valentinstag? Wir verraten, was sich hier wirklich lohnt.',
155 'skip_download': True,
159 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist',
162 'title': 'Episode 8 - Ganze Folge - Playlist',
163 'description': 'md5:63b8963e71f481782aeea877658dec84',
170 r
'"clip_id"\s*:\s+"(\d+)"',
173 r
"'itemImageUrl'\s*:\s*'/dynamic/thumbnails/full/\d+/(\d+)",
176 r
'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
177 r
'<header class="clearfix">\s*<h3>(.+?)</h3>',
178 r
'<!-- start video -->\s*<h1>(.+?)</h1>',
179 r
'<h1 class="att-name">\s*(.+?)</h1>',
181 _DESCRIPTION_REGEXES
= [
182 r
'<p itemprop="description">\s*(.+?)</p>',
183 r
'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
184 r
'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
185 r
'<p class="att-description">\s*(.+?)\s*</p>',
187 _UPLOAD_DATE_REGEXES
= [
188 r
'<meta property="og:published_time" content="(.+?)">',
189 r
'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"',
190 r
'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
191 r
'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
192 r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
194 _PAGE_TYPE_REGEXES
= [
195 r
'<meta name="page_type" content="([^"]+)">',
196 r
"'itemType'\s*:\s*'([^']*)'",
198 _PLAYLIST_ID_REGEXES
= [
199 r
'content[iI]d=(\d+)',
200 r
"'itemId'\s*:\s*'([^']*)'",
202 _PLAYLIST_CLIP_REGEXES
= [
203 r
'(?s)data-qvt=.+?<a href="([^"]+)"',
206 def _extract_clip(self
, url
, webpage
):
207 clip_id
= self
._html
_search
_regex
(self
._CLIPID
_REGEXES
, webpage
, 'clip id')
209 access_token
= 'testclient'
210 client_name
= 'kolibri-1.2.5'
211 client_location
= url
213 videos_api_url
= 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse
.urlencode({
214 'access_token': access_token
,
215 'client_location': client_location
,
216 'client_name': client_name
,
220 videos
= self
._download
_json
(videos_api_url
, clip_id
, 'Downloading videos JSON')
222 duration
= float(videos
[0]['duration'])
223 source_ids
= [source
['id'] for source
in videos
[0]['sources']]
224 source_ids_str
= ','.join(map(str, source_ids
))
226 g
= '01!8d8F_)r9]4s[qeuXfP%'
228 client_id
= g
[:2] + sha1(''.join([clip_id
, g
, access_token
, client_location
, g
, client_name
])
229 .encode('utf-8')).hexdigest()
231 sources_api_url
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id
, compat_urllib_parse
.urlencode({
232 'access_token': access_token
,
233 'client_id': client_id
,
234 'client_location': client_location
,
235 'client_name': client_name
,
238 sources
= self
._download
_json
(sources_api_url
, clip_id
, 'Downloading sources JSON')
239 server_id
= sources
['server_id']
241 client_id
= g
[:2] + sha1(''.join([g
, clip_id
, access_token
, server_id
,
242 client_location
, source_ids_str
, g
, client_name
])
243 .encode('utf-8')).hexdigest()
245 url_api_url
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id
, compat_urllib_parse
.urlencode({
246 'access_token': access_token
,
247 'client_id': client_id
,
248 'client_location': client_location
,
249 'client_name': client_name
,
250 'server_id': server_id
,
251 'source_ids': source_ids_str
,
254 urls
= self
._download
_json
(url_api_url
, clip_id
, 'Downloading urls JSON')
256 title
= self
._html
_search
_regex
(self
._TITLE
_REGEXES
, webpage
, 'title')
257 description
= self
._html
_search
_regex
(self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False)
258 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
260 upload_date
= unified_strdate(self
._html
_search
_regex
(
261 self
._UPLOAD
_DATE
_REGEXES
, webpage
, 'upload date', default
=None))
265 urls_sources
= urls
['sources']
266 if isinstance(urls_sources
, dict):
267 urls_sources
= urls_sources
.values()
269 def fix_bitrate(bitrate
):
270 bitrate
= int_or_none(bitrate
)
273 return (bitrate
// 1000) if bitrate
% 1000 == 0 else bitrate
275 for source
in urls_sources
:
276 protocol
= source
['protocol']
277 if protocol
== 'rtmp' or protocol
== 'rtmpe':
278 mobj
= re
.search(r
'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source
['url'])
282 'url': mobj
.group('url'),
283 'app': mobj
.group('app'),
284 'play_path': mobj
.group('playpath'),
285 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
286 'page_url': 'http://www.prosieben.de',
287 'vbr': fix_bitrate(source
['bitrate']),
289 'format_id': '%s_%s' % (source
['cdn'], source
['bitrate']),
293 'url': source
['url'],
294 'vbr': fix_bitrate(source
['bitrate']),
297 self
._sort
_formats
(formats
)
302 'description': description
,
303 'thumbnail': thumbnail
,
304 'upload_date': upload_date
,
305 'duration': duration
,
309 def _extract_playlist(self
, url
, webpage
):
310 playlist_id
= self
._html
_search
_regex
(
311 self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id')
312 for regex
in self
._PLAYLIST
_CLIP
_REGEXES
:
313 playlist_clips
= re
.findall(regex
, webpage
)
315 title
= self
._html
_search
_regex
(
316 self
._TITLE
_REGEXES
, webpage
, 'title')
317 description
= self
._html
_search
_regex
(
318 self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False)
321 re
.match('(.+?//.+?)/', url
).group(1) + clip_path
,
323 for clip_path
in playlist_clips
]
324 return self
.playlist_result(entries
, playlist_id
, title
, description
)
326 def _real_extract(self
, url
):
327 video_id
= self
._match
_id
(url
)
328 webpage
= self
._download
_webpage
(url
, video_id
)
329 page_type
= self
._search
_regex
(
330 self
._PAGE
_TYPE
_REGEXES
, webpage
,
331 'page type', default
='clip').lower()
332 if page_type
== 'clip':
333 return self
._extract
_clip
(url
, webpage
)
334 elif page_type
== 'playlist':
335 return self
._extract
_playlist
(url
, webpage
)