2 from __future__ import unicode_literals
6 from hashlib import sha1
7 from .common import InfoExtractor
15 class ProSiebenSat1IE(InfoExtractor):
16 IE_NAME = 'prosiebensat1'
17 IE_DESC = 'ProSiebenSat.1 Digital'
18 _VALID_URL = r'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|ran|the-voice-of-germany)\.de|fem\.com)/(?P<id>.+)'
22 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
26 'title': 'Staffel 2, Episode 18 - Jahresrückblick',
27 'description': 'md5:8733c81b702ea472e069bc48bb658fc1',
28 'upload_date': '20131231',
33 'skip_download': True,
37 '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',
41 'title': 'Lady-Umstyling für Audrina',
42 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d',
43 'upload_date': '20131014',
48 'skip_download': True,
50 'skip': 'Seems to be broken',
53 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge',
57 'title': 'Countdown für die Autowerkstatt',
58 'description': 'md5:809fc051a457b5d8666013bc40698817',
59 'upload_date': '20140223',
64 'skip_download': True,
68 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
72 'title': 'Sexy laufen in Ugg Boots',
73 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
74 'upload_date': '20140122',
79 'skip_download': True,
83 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
87 'title': 'Im Interview: Kai Wiesinger',
88 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
89 'upload_date': '20140203',
94 'skip_download': True,
98 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
102 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
103 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
104 'upload_date': '20141014',
109 'skip_download': True,
113 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
117 'title': 'Schalke: Tönnies möchte Raul zurück',
118 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
119 'upload_date': '20140226',
124 'skip_download': True,
128 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
132 'title': 'Andreas Kümmert: Rocket Man',
133 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
134 'upload_date': '20131017',
139 'skip_download': True,
143 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html',
147 'title': 'Kurztrips zum Valentinstag',
148 'description': 'Romantischer Kurztrip zum Valentinstag? Wir verraten, was sich hier wirklich lohnt.',
153 'skip_download': True,
157 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist',
160 'title': 'Episode 8 - Ganze Folge - Playlist',
161 'description': 'Das finale und härteste Duell aller Zeiten ist vorbei! Der Weltmeister für dieses Jahr steht! Alle packenden Duelle der achten Episode von "Joko gegen Klaas - das Duell um die Welt" seht ihr hier noch einmal in voller Länge!',
168 r'"clip_id"\s*:\s+"(\d+)"',
171 r"'itemImageUrl'\s*:\s*'/dynamic/thumbnails/full/\d+/(\d+)",
174 r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
175 r'<header class="clearfix">\s*<h3>(.+?)</h3>',
176 r'<!-- start video -->\s*<h1>(.+?)</h1>',
177 r'<h1 class="att-name">\s*(.+?)</h1>',
179 _DESCRIPTION_REGEXES = [
180 r'<p itemprop="description">\s*(.+?)</p>',
181 r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
182 r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
183 r'<p class="att-description">\s*(.+?)\s*</p>',
185 _UPLOAD_DATE_REGEXES = [
186 r'<meta property="og:published_time" content="(.+?)">',
187 r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"',
188 r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
189 r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
190 r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
192 _ITEM_TYPE_REGEXES = [
193 r"'itemType'\s*:\s*'([^']*)'",
196 r"'itemId'\s*:\s*'([^']*)'",
198 _PLAYLIST_CLIPS_REGEXES = [
199 r'data-qvt=.+?<a href="([^"]+)"',
202 def _real_extract(self, url):
203 video_id = self._match_id(url)
204 webpage = self._download_webpage(url, video_id)
206 item_type = self._html_search_regex(self._ITEM_TYPE_REGEXES, webpage, 'item type', default='CLIP')
207 if item_type == 'CLIP':
208 return self._clip_extract(url, webpage)
209 elif item_type == 'PLAYLIST':
210 playlist_id = self._html_search_regex(self._ITEM_ID_REGEXES, webpage, 'playlist id')
212 for regex in self._PLAYLIST_CLIPS_REGEXES:
213 playlist_clips = re.findall(regex, webpage, re.DOTALL)
215 title = self._html_search_regex(self._TITLE_REGEXES, webpage, 'title')
216 description = self._html_search_regex(self._DESCRIPTION_REGEXES, webpage, 'description', fatal=False)
217 root_url = re.match('(.+?//.+?)/', url).group(1)
223 'description': description,
224 'entries': [self._clip_extract(root_url + clip_path) for clip_path in playlist_clips]
227 raise ExtractorError('Unknown item type "%s"' % item_type)
229 def _clip_extract(self, url, webpage=None):
231 video_id = self._match_id(url)
232 webpage = self._download_webpage(url, video_id)
234 clip_id = self._html_search_regex(self._CLIPID_REGEXES, webpage, 'clip id')
236 access_token = 'testclient'
237 client_name = 'kolibri-1.2.5'
238 client_location = url
240 videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({
241 'access_token': access_token,
242 'client_location': client_location,
243 'client_name': client_name,
247 videos = self._download_json(videos_api_url, clip_id, 'Downloading videos JSON')
249 duration = float(videos[0]['duration'])
250 source_ids = [source['id'] for source in videos[0]['sources']]
251 source_ids_str = ','.join(map(str, source_ids))
253 g = '01!8d8F_)r9]4s[qeuXfP%'
255 client_id = g[:2] + sha1(''.join([clip_id, g, access_token, client_location, g, client_name])
256 .encode('utf-8')).hexdigest()
258 sources_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id, compat_urllib_parse.urlencode({
259 'access_token': access_token,
260 'client_id': client_id,
261 'client_location': client_location,
262 'client_name': client_name,
265 sources = self._download_json(sources_api_url, clip_id, 'Downloading sources JSON')
266 server_id = sources['server_id']
268 client_id = g[:2] + sha1(''.join([g, clip_id, access_token, server_id,
269 client_location, source_ids_str, g, client_name])
270 .encode('utf-8')).hexdigest()
272 url_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id, compat_urllib_parse.urlencode({
273 'access_token': access_token,
274 'client_id': client_id,
275 'client_location': client_location,
276 'client_name': client_name,
277 'server_id': server_id,
278 'source_ids': source_ids_str,
281 urls = self._download_json(url_api_url, clip_id, 'Downloading urls JSON')
283 title = self._html_search_regex(self._TITLE_REGEXES, webpage, 'title')
284 description = self._html_search_regex(self._DESCRIPTION_REGEXES, webpage, 'description', fatal=False)
285 thumbnail = self._og_search_thumbnail(webpage)
287 upload_date = unified_strdate(self._html_search_regex(
288 self._UPLOAD_DATE_REGEXES, webpage, 'upload date', default=None))
292 urls_sources = urls['sources']
293 if isinstance(urls_sources, dict):
294 urls_sources = urls_sources.values()
296 def fix_bitrate(bitrate):
297 return (bitrate // 1000) if bitrate % 1000 == 0 else bitrate
299 for source in urls_sources:
300 protocol = source['protocol']
301 if protocol == 'rtmp' or protocol == 'rtmpe':
302 mobj = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source['url'])
306 'url': mobj.group('url'),
307 'app': mobj.group('app'),
308 'play_path': mobj.group('playpath'),
309 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
310 'page_url': 'http://www.prosieben.de',
311 'vbr': fix_bitrate(source['bitrate']),
313 'format_id': '%s_%s' % (source['cdn'], source['bitrate']),
317 'url': source['url'],
318 'vbr': fix_bitrate(source['bitrate']),
321 self._sort_formats(formats)
326 'description': description,
327 'thumbnail': thumbnail,
328 'upload_date': upload_date,
329 'duration': duration,