]>
Commit | Line | Data |
---|---|---|
0c7214c4 S |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from hashlib import sha1 | |
7 | from .common import InfoExtractor | |
8 | from ..utils import ( | |
9 | compat_urllib_parse, | |
10 | unified_strdate, | |
11 | clean_html, | |
12 | RegexNotFoundError, | |
13 | ) | |
14 | ||
15 | ||
16 | class ProSiebenSat1IE(InfoExtractor): | |
17 | IE_NAME = 'prosiebensat1' | |
18 | IE_DESC = 'ProSiebenSat.1 Digital' | |
19 | _VALID_URL = r'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|ran|the-voice-of-germany)\.de|fem\.com)/(?P<id>.+)' | |
20 | ||
21 | _TESTS = [ | |
22 | { | |
23 | 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', | |
24 | 'info_dict': { | |
25 | 'id': '2104602', | |
26 | 'ext': 'mp4', | |
27 | 'title': 'Staffel 2, Episode 18 - Jahresrückblick', | |
28 | 'description': 'md5:8733c81b702ea472e069bc48bb658fc1', | |
29 | 'upload_date': '20131231', | |
30 | 'duration': 5845.04, | |
31 | }, | |
32 | 'params': { | |
33 | # rtmp download | |
34 | 'skip_download': True, | |
35 | }, | |
36 | }, | |
37 | { | |
38 | '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', | |
39 | 'info_dict': { | |
40 | 'id': '2570327', | |
41 | 'ext': 'mp4', | |
42 | 'title': 'Lady-Umstyling für Audrina', | |
43 | 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d', | |
44 | 'upload_date': '20131014', | |
45 | 'duration': 606.76, | |
46 | }, | |
47 | 'params': { | |
48 | # rtmp download | |
49 | 'skip_download': True, | |
50 | }, | |
51 | 'skip': 'Seems to be broken', | |
52 | }, | |
53 | { | |
54 | 'url': 'http://www.prosiebenmaxx.de/yep/one-piece/video/148-folge-48-gold-rogers-heimat-ganze-folge', | |
55 | 'info_dict': { | |
56 | 'id': '2437108', | |
57 | 'ext': 'mp4', | |
58 | 'title': 'Folge 48: Gold Rogers Heimat', | |
59 | 'description': 'Ruffy erreicht die Insel, auf der der berühmte Gold Roger lebte und hingerichtet wurde.', | |
60 | 'upload_date': '20140226', | |
61 | 'duration': 1401.48, | |
62 | }, | |
63 | 'params': { | |
64 | # rtmp download | |
65 | 'skip_download': True, | |
66 | }, | |
67 | }, | |
68 | { | |
69 | 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip', | |
70 | 'info_dict': { | |
71 | 'id': '2904997', | |
72 | 'ext': 'mp4', | |
73 | 'title': 'Sexy laufen in Ugg Boots', | |
74 | 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6', | |
75 | 'upload_date': '20140122', | |
76 | 'duration': 245.32, | |
77 | }, | |
78 | 'params': { | |
79 | # rtmp download | |
80 | 'skip_download': True, | |
81 | }, | |
82 | }, | |
83 | { | |
84 | 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip', | |
85 | 'info_dict': { | |
86 | 'id': '2906572', | |
87 | 'ext': 'mp4', | |
88 | 'title': 'Im Interview: Kai Wiesinger', | |
89 | 'description': 'md5:e4e5370652ec63b95023e914190b4eb9', | |
90 | 'upload_date': '20140225', | |
91 | 'duration': 522.56, | |
92 | }, | |
93 | 'params': { | |
94 | # rtmp download | |
95 | 'skip_download': True, | |
96 | }, | |
97 | }, | |
98 | { | |
99 | 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge', | |
100 | 'info_dict': { | |
101 | 'id': '2992323', | |
102 | 'ext': 'mp4', | |
103 | 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2', | |
104 | 'description': 'md5:2669cde3febe9bce13904f701e774eb6', | |
105 | 'upload_date': '20140225', | |
106 | 'duration': 2410.44, | |
107 | }, | |
108 | 'params': { | |
109 | # rtmp download | |
110 | 'skip_download': True, | |
111 | }, | |
112 | }, | |
113 | { | |
114 | 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge', | |
115 | 'info_dict': { | |
116 | 'id': '3004256', | |
117 | 'ext': 'mp4', | |
118 | 'title': 'Schalke: Tönnies möchte Raul zurück', | |
119 | 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f', | |
120 | 'upload_date': '20140226', | |
121 | 'duration': 228.96, | |
122 | }, | |
123 | 'params': { | |
124 | # rtmp download | |
125 | 'skip_download': True, | |
126 | }, | |
127 | }, | |
128 | { | |
129 | 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip', | |
130 | 'info_dict': { | |
131 | 'id': '2572814', | |
132 | 'ext': 'mp4', | |
133 | 'title': 'Andreas Kümmert: Rocket Man', | |
134 | 'description': 'md5:6ddb02b0781c6adf778afea606652e38', | |
135 | 'upload_date': '20131017', | |
136 | 'duration': 469.88, | |
137 | }, | |
138 | 'params': { | |
139 | # rtmp download | |
140 | 'skip_download': True, | |
141 | }, | |
142 | }, | |
143 | { | |
144 | 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html', | |
145 | 'info_dict': { | |
146 | 'id': '2156342', | |
147 | 'ext': 'mp4', | |
148 | 'title': 'Kurztrips zum Valentinstag', | |
149 | 'description': 'md5:8ba6301e70351ae0bedf8da00f7ba528', | |
150 | 'upload_date': '20130206', | |
151 | 'duration': 307.24, | |
152 | }, | |
153 | 'params': { | |
154 | # rtmp download | |
155 | 'skip_download': True, | |
156 | }, | |
157 | }, | |
158 | ] | |
159 | ||
160 | _CLIPID_REGEXES = [ | |
161 | r'"clip_id"\s*:\s+"(\d+)"', | |
162 | r'clipid: "(\d+)"', | |
163 | ] | |
164 | _TITLE_REGEXES = [ | |
165 | r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>', | |
166 | r'<header class="clearfix">\s*<h3>(.+?)</h3>', | |
167 | r'<!-- start video -->\s*<h1>(.+?)</h1>', | |
168 | r'<div class="ep-femvideos-pi4-video-txt">\s*<h2>(.+?)</h2>', | |
169 | ] | |
170 | _DESCRIPTION_REGEXES = [ | |
171 | r'<p itemprop="description">\s*(.+?)</p>', | |
172 | r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>', | |
173 | r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>', | |
174 | r'<p>(.+?)</p>\s*<div class="ep-femvideos-pi4-video-footer">', | |
175 | ] | |
176 | _UPLOAD_DATE_REGEXES = [ | |
177 | r'<meta property="og:published_time" content="(.+?)">', | |
178 | r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"', | |
179 | r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr', | |
180 | r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>', | |
181 | r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>', | |
182 | ] | |
183 | ||
184 | def _real_extract(self, url): | |
185 | mobj = re.match(self._VALID_URL, url) | |
186 | video_id = mobj.group('id') | |
187 | ||
188 | page = self._download_webpage(url, video_id, 'Downloading page') | |
189 | ||
190 | def extract(patterns, name, page, fatal=False): | |
191 | for pattern in patterns: | |
192 | mobj = re.search(pattern, page) | |
193 | if mobj: | |
194 | return clean_html(mobj.group(1)) | |
195 | if fatal: | |
196 | raise RegexNotFoundError(u'Unable to extract %s' % name) | |
197 | return None | |
198 | ||
199 | clip_id = extract(self._CLIPID_REGEXES, 'clip id', page, fatal=True) | |
200 | ||
201 | access_token = 'testclient' | |
202 | client_name = 'kolibri-1.2.5' | |
203 | client_location = url | |
204 | ||
205 | videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({ | |
206 | 'access_token': access_token, | |
207 | 'client_location': client_location, | |
208 | 'client_name': client_name, | |
209 | 'ids': clip_id, | |
210 | }) | |
211 | ||
212 | videos = self._download_json(videos_api_url, clip_id, 'Downloading videos JSON') | |
213 | ||
214 | duration = float(videos[0]['duration']) | |
215 | source_ids = [source['id'] for source in videos[0]['sources']] | |
216 | source_ids_str = ','.join(map(str, source_ids)) | |
217 | ||
218 | g = '01!8d8F_)r9]4s[qeuXfP%' | |
219 | ||
220 | client_id = g[:2] + sha1(''.join([clip_id, g, access_token, client_location, g, client_name]) | |
221 | .encode('utf-8')).hexdigest() | |
222 | ||
223 | sources_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id, compat_urllib_parse.urlencode({ | |
224 | 'access_token': access_token, | |
225 | 'client_id': client_id, | |
226 | 'client_location': client_location, | |
227 | 'client_name': client_name, | |
228 | })) | |
229 | ||
230 | sources = self._download_json(sources_api_url, clip_id, 'Downloading sources JSON') | |
231 | server_id = sources['server_id'] | |
232 | ||
233 | client_id = g[:2] + sha1(''.join([g, clip_id, access_token, server_id, | |
234 | client_location, source_ids_str, g, client_name]) | |
235 | .encode('utf-8')).hexdigest() | |
236 | ||
237 | url_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id, compat_urllib_parse.urlencode({ | |
238 | 'access_token': access_token, | |
239 | 'client_id': client_id, | |
240 | 'client_location': client_location, | |
241 | 'client_name': client_name, | |
242 | 'server_id': server_id, | |
243 | 'source_ids': source_ids_str, | |
244 | })) | |
245 | ||
246 | urls = self._download_json(url_api_url, clip_id, 'Downloading urls JSON') | |
247 | ||
248 | title = extract(self._TITLE_REGEXES, 'title', page, fatal=True) | |
249 | description = extract(self._DESCRIPTION_REGEXES, 'description', page) | |
250 | thumbnail = self._og_search_thumbnail(page) | |
251 | ||
252 | upload_date = extract(self._UPLOAD_DATE_REGEXES, 'upload date', page) | |
253 | if upload_date: | |
254 | upload_date = unified_strdate(upload_date) | |
255 | ||
256 | formats = [] | |
257 | ||
258 | urls_sources = urls['sources'] | |
259 | if isinstance(urls_sources, dict): | |
260 | urls_sources = urls_sources.values() | |
261 | ||
262 | def fix_bitrate(bitrate): | |
263 | return bitrate / 1000 if bitrate % 1000 == 0 else bitrate | |
264 | ||
265 | for source in urls_sources: | |
8a44ef68 S |
266 | protocol = source['protocol'] |
267 | if protocol == 'rtmp' or protocol == 'rtmpe': | |
268 | mobj = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source['url']) | |
0c7214c4 S |
269 | if not mobj: |
270 | continue | |
271 | formats.append({ | |
272 | 'url': mobj.group('url'), | |
273 | 'app': mobj.group('app'), | |
274 | 'play_path': mobj.group('playpath'), | |
275 | 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf', | |
276 | 'page_url': 'http://www.prosieben.de', | |
277 | 'vbr': fix_bitrate(source['bitrate']), | |
278 | 'ext': 'mp4', | |
279 | 'format_id': '%s_%s' % (source['cdn'], source['bitrate']), | |
280 | }) | |
281 | else: | |
282 | formats.append({ | |
283 | 'url': source['url'], | |
a9ab8855 | 284 | 'vbr': fix_bitrate(source['bitrate']), |
0c7214c4 S |
285 | }) |
286 | ||
287 | self._sort_formats(formats) | |
288 | ||
289 | return { | |
290 | 'id': clip_id, | |
291 | 'title': title, | |
292 | 'description': description, | |
293 | 'thumbnail': thumbnail, | |
294 | 'upload_date': upload_date, | |
295 | 'duration': duration, | |
296 | 'formats': formats, | |
297 | } |