]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
9148eb00 PH |
2 | from __future__ import unicode_literals |
3 | ||
79fec976 | 4 | import base64 |
eb9c9c74 | 5 | import functools |
b3d14cbf | 6 | import re |
caeefc29 | 7 | import itertools |
b3d14cbf PH |
8 | |
9 | from .common import InfoExtractor | |
8c25f81b | 10 | from ..compat import ( |
eb9c9c74 | 11 | compat_kwargs, |
1060425c | 12 | compat_HTTPError, |
6a55bb66 | 13 | compat_str, |
9c44d242 | 14 | compat_urlparse, |
8c25f81b PH |
15 | ) |
16 | from ..utils import ( | |
681ac7c9 | 17 | clean_html, |
d5f071af | 18 | determine_ext, |
b3d14cbf | 19 | ExtractorError, |
58ab5cbc | 20 | get_element_by_class, |
9cb070f9 | 21 | HEADRequest, |
ca01d178 | 22 | js_to_json, |
9c44d242 | 23 | int_or_none, |
ae1c585c | 24 | merge_dicts, |
eb9c9c74 | 25 | OnDemandPagedList, |
ca01d178 | 26 | parse_filesize, |
cce889b9 | 27 | parse_iso8601, |
4dfbf869 | 28 | parse_qs, |
67dda517 | 29 | sanitized_Request, |
30965ac6 | 30 | smuggle_url, |
681ac7c9 | 31 | str_or_none, |
c15cd296 | 32 | try_get, |
c15cd296 | 33 | unified_timestamp, |
9d4660ca | 34 | unsmuggle_url, |
a980bc43 | 35 | urlencode_postdata, |
1c45ff55 | 36 | urljoin, |
b407e173 | 37 | unescapeHTML, |
9cb070f9 | 38 | urlhandle_detect_ext, |
b3d14cbf PH |
39 | ) |
40 | ||
bbafbe20 | 41 | |
efb7e119 JMF |
42 | class VimeoBaseInfoExtractor(InfoExtractor): |
43 | _NETRC_MACHINE = 'vimeo' | |
44 | _LOGIN_REQUIRED = False | |
f6c3664d | 45 | _LOGIN_URL = 'https://vimeo.com/log_in' |
efb7e119 JMF |
46 | |
47 | def _login(self): | |
68217024 | 48 | username, password = self._get_login_info() |
efb7e119 JMF |
49 | if username is None: |
50 | if self._LOGIN_REQUIRED: | |
4f3e9430 | 51 | raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True) |
efb7e119 | 52 | return |
26ad6bcd S |
53 | webpage = self._download_webpage( |
54 | self._LOGIN_URL, None, 'Downloading login page') | |
7c845629 | 55 | token, vuid = self._extract_xsrft_and_vuid(webpage) |
26ad6bcd | 56 | data = { |
f6c3664d | 57 | 'action': 'login', |
efb7e119 JMF |
58 | 'email': username, |
59 | 'password': password, | |
efb7e119 JMF |
60 | 'service': 'vimeo', |
61 | 'token': token, | |
26ad6bcd | 62 | } |
9eab37dc | 63 | self._set_vimeo_cookie('vuid', vuid) |
26ad6bcd S |
64 | try: |
65 | self._download_webpage( | |
66 | self._LOGIN_URL, None, 'Logging in', | |
67 | data=urlencode_postdata(data), headers={ | |
68 | 'Content-Type': 'application/x-www-form-urlencoded', | |
69 | 'Referer': self._LOGIN_URL, | |
70 | }) | |
71 | except ExtractorError as e: | |
72 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 418: | |
73 | raise ExtractorError( | |
74 | 'Unable to log in: bad username or password', | |
75 | expected=True) | |
76 | raise ExtractorError('Unable to log in') | |
efb7e119 | 77 | |
cce889b9 | 78 | def _get_video_password(self): |
a06916d9 | 79 | password = self.get_param('videopassword') |
c1ff6e1a | 80 | if password is None: |
cce889b9 | 81 | raise ExtractorError( |
82 | 'This video is protected by a password, use the --video-password option', | |
83 | expected=True) | |
84 | return password | |
85 | ||
86 | def _verify_video_password(self, url, video_id, password, token, vuid): | |
c1ff6e1a YCH |
87 | if url.startswith('http://'): |
88 | # vimeo only supports https now, but the user can give an http url | |
89 | url = url.replace('http://', 'https://') | |
c1ff6e1a YCH |
90 | self._set_vimeo_cookie('vuid', vuid) |
91 | return self._download_webpage( | |
cce889b9 | 92 | url + '/password', video_id, 'Verifying the password', |
93 | 'Wrong password', data=urlencode_postdata({ | |
94 | 'password': password, | |
95 | 'token': token, | |
96 | }), headers={ | |
97 | 'Content-Type': 'application/x-www-form-urlencoded', | |
98 | 'Referer': url, | |
99 | }) | |
c1ff6e1a | 100 | |
7c845629 S |
101 | def _extract_xsrft_and_vuid(self, webpage): |
102 | xsrft = self._search_regex( | |
b826035d | 103 | r'(?:(?P<q1>["\'])xsrft(?P=q1)\s*:|xsrft\s*[=:])\s*(?P<q>["\'])(?P<xsrft>.+?)(?P=q)', |
f6c3664d | 104 | webpage, 'login token', group='xsrft') |
7c845629 S |
105 | vuid = self._search_regex( |
106 | r'["\']vuid["\']\s*:\s*(["\'])(?P<vuid>.+?)\1', | |
107 | webpage, 'vuid', group='vuid') | |
108 | return xsrft, vuid | |
f6c3664d | 109 | |
eb9c9c74 RA |
110 | def _extract_vimeo_config(self, webpage, video_id, *args, **kwargs): |
111 | vimeo_config = self._search_regex( | |
112 | r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));', | |
113 | webpage, 'vimeo config', *args, **compat_kwargs(kwargs)) | |
114 | if vimeo_config: | |
115 | return self._parse_json(vimeo_config, video_id) | |
116 | ||
9eab37dc S |
117 | def _set_vimeo_cookie(self, name, value): |
118 | self._set_cookie('vimeo.com', name, value) | |
119 | ||
531a7496 | 120 | def _vimeo_sort_formats(self, formats): |
bc104778 | 121 | # Note: Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps |
122 | # at the same time without actual units specified. | |
123 | self._sort_formats(formats, ('quality', 'res', 'fps', 'hdr:12', 'source')) | |
531a7496 YCH |
124 | |
125 | def _parse_config(self, config, video_id): | |
d8c507c9 | 126 | video_data = config['video'] |
d8c507c9 | 127 | video_title = video_data['title'] |
85b6335d RA |
128 | live_event = video_data.get('live_event') or {} |
129 | is_live = live_event.get('status') == 'started' | |
58ab5cbc | 130 | request = config.get('request') or {} |
531a7496 YCH |
131 | |
132 | formats = [] | |
3f047fc4 F |
133 | subtitles = {} |
134 | ||
58ab5cbc | 135 | config_files = video_data.get('files') or request.get('files') or {} |
136 | for f in (config_files.get('progressive') or []): | |
531a7496 YCH |
137 | video_url = f.get('url') |
138 | if not video_url: | |
139 | continue | |
140 | formats.append({ | |
141 | 'url': video_url, | |
142 | 'format_id': 'http-%s' % f.get('quality'), | |
bc104778 | 143 | 'source_preference': 10, |
531a7496 YCH |
144 | 'width': int_or_none(f.get('width')), |
145 | 'height': int_or_none(f.get('height')), | |
146 | 'fps': int_or_none(f.get('fps')), | |
147 | 'tbr': int_or_none(f.get('bitrate')), | |
148 | }) | |
d8c507c9 | 149 | |
85b6335d | 150 | # TODO: fix handling of 308 status code returned for live archive manifest requests |
52c50a10 | 151 | sep_pattern = r'/sep/video/' |
d8c507c9 | 152 | for files_type in ('hls', 'dash'): |
58ab5cbc | 153 | for cdn_name, cdn_data in (try_get(config_files, lambda x: x[files_type]['cdns']) or {}).items(): |
d8c507c9 RA |
154 | manifest_url = cdn_data.get('url') |
155 | if not manifest_url: | |
156 | continue | |
157 | format_id = '%s-%s' % (files_type, cdn_name) | |
52c50a10 RA |
158 | sep_manifest_urls = [] |
159 | if re.search(sep_pattern, manifest_url): | |
160 | for suffix, repl in (('', 'video'), ('_sep', 'sep/video')): | |
161 | sep_manifest_urls.append((format_id + suffix, re.sub( | |
162 | sep_pattern, '/%s/' % repl, manifest_url))) | |
163 | else: | |
164 | sep_manifest_urls = [(format_id, manifest_url)] | |
165 | for f_id, m_url in sep_manifest_urls: | |
166 | if files_type == 'hls': | |
3f047fc4 | 167 | fmts, subs = self._extract_m3u8_formats_and_subtitles( |
a5c0c202 | 168 | m_url, video_id, 'mp4', live=is_live, m3u8_id=f_id, |
52c50a10 | 169 | note='Downloading %s m3u8 information' % cdn_name, |
3f047fc4 F |
170 | fatal=False) |
171 | formats.extend(fmts) | |
172 | self._merge_subtitles(subs, target=subtitles) | |
52c50a10 | 173 | elif files_type == 'dash': |
c25720ef RA |
174 | if 'json=1' in m_url: |
175 | real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url') | |
176 | if real_m_url: | |
177 | m_url = real_m_url | |
3f047fc4 | 178 | fmts, subs = self._extract_mpd_formats_and_subtitles( |
ae9a173b RA |
179 | m_url.replace('/master.json', '/master.mpd'), video_id, f_id, |
180 | 'Downloading %s MPD information' % cdn_name, | |
e834f044 | 181 | fatal=False) |
3f047fc4 F |
182 | formats.extend(fmts) |
183 | self._merge_subtitles(subs, target=subtitles) | |
531a7496 | 184 | |
85b6335d RA |
185 | live_archive = live_event.get('archive') or {} |
186 | live_archive_source_url = live_archive.get('source_url') | |
187 | if live_archive_source_url and live_archive.get('status') == 'done': | |
188 | formats.append({ | |
189 | 'format_id': 'live-archive-source', | |
190 | 'url': live_archive_source_url, | |
f983b875 | 191 | 'quality': 10, |
85b6335d RA |
192 | }) |
193 | ||
58ab5cbc | 194 | for tt in (request.get('text_tracks') or []): |
3f047fc4 | 195 | subtitles.setdefault(tt['lang'], []).append({ |
58ab5cbc | 196 | 'ext': 'vtt', |
197 | 'url': urljoin('https://vimeo.com', tt['url']), | |
3f047fc4 | 198 | }) |
531a7496 | 199 | |
c25720ef RA |
200 | thumbnails = [] |
201 | if not is_live: | |
58ab5cbc | 202 | for key, thumb in (video_data.get('thumbs') or {}).items(): |
c25720ef RA |
203 | thumbnails.append({ |
204 | 'id': key, | |
205 | 'width': int_or_none(key), | |
206 | 'url': thumb, | |
207 | }) | |
208 | thumbnail = video_data.get('thumbnail') | |
209 | if thumbnail: | |
210 | thumbnails.append({ | |
211 | 'url': thumbnail, | |
212 | }) | |
213 | ||
214 | owner = video_data.get('owner') or {} | |
215 | video_uploader_url = owner.get('url') | |
216 | ||
818faa3a | 217 | duration = int_or_none(video_data.get('duration')) |
218 | chapter_data = try_get(config, lambda x: x['embed']['chapters']) or [] | |
219 | chapters = [{ | |
220 | 'title': current_chapter.get('title'), | |
221 | 'start_time': current_chapter.get('timecode'), | |
222 | 'end_time': next_chapter.get('timecode'), | |
223 | } for current_chapter, next_chapter in zip(chapter_data, chapter_data[1:] + [{'timecode': duration}])] | |
224 | if chapters and chapters[0]['start_time']: # Chapters may not start from 0 | |
225 | chapters[:0] = [{'title': '<Untitled>', 'start_time': 0, 'end_time': chapters[0]['start_time']}] | |
226 | ||
531a7496 | 227 | return { |
681ac7c9 | 228 | 'id': str_or_none(video_data.get('id')) or video_id, |
39ca3b5c | 229 | 'title': video_title, |
c25720ef RA |
230 | 'uploader': owner.get('name'), |
231 | 'uploader_id': video_uploader_url.split('/')[-1] if video_uploader_url else None, | |
531a7496 | 232 | 'uploader_url': video_uploader_url, |
c25720ef | 233 | 'thumbnails': thumbnails, |
818faa3a | 234 | 'duration': duration, |
235 | 'chapters': chapters or None, | |
531a7496 YCH |
236 | 'formats': formats, |
237 | 'subtitles': subtitles, | |
c25720ef | 238 | 'is_live': is_live, |
531a7496 YCH |
239 | } |
240 | ||
bc2ca1bb | 241 | def _extract_original_format(self, url, video_id, unlisted_hash=None): |
242 | query = {'action': 'load_download_config'} | |
243 | if unlisted_hash: | |
244 | query['unlisted_hash'] = unlisted_hash | |
27655037 | 245 | download_data = self._download_json( |
bc2ca1bb | 246 | url, video_id, fatal=False, query=query, |
9cb070f9 | 247 | headers={'X-Requested-With': 'XMLHttpRequest'}, |
248 | expected_status=(403, 404)) or {} | |
249 | source_file = download_data.get('source_file') | |
250 | download_url = try_get(source_file, lambda x: x['download_url']) | |
251 | if download_url and not source_file.get('is_cold') and not source_file.get('is_defrosting'): | |
252 | source_name = source_file.get('public_name', 'Original') | |
253 | if self._is_valid_url(download_url, video_id, '%s video' % source_name): | |
254 | ext = (try_get( | |
255 | source_file, lambda x: x['extension'], | |
256 | compat_str) or determine_ext( | |
257 | download_url, None) or 'mp4').lower() | |
258 | return { | |
259 | 'url': download_url, | |
260 | 'ext': ext, | |
261 | 'width': int_or_none(source_file.get('width')), | |
262 | 'height': int_or_none(source_file.get('height')), | |
263 | 'filesize': parse_filesize(source_file.get('size')), | |
264 | 'format_id': source_name, | |
265 | 'quality': 1, | |
266 | } | |
27655037 | 267 | |
605cad0b A |
268 | jwt_response = self._download_json( |
269 | 'https://vimeo.com/_rv/viewer', video_id, note='Downloading jwt token', fatal=False) or {} | |
270 | if not jwt_response.get('jwt'): | |
271 | return | |
272 | headers = {'Authorization': 'jwt %s' % jwt_response['jwt']} | |
273 | original_response = self._download_json( | |
274 | f'https://api.vimeo.com/videos/{video_id}', video_id, | |
9cb070f9 | 275 | headers=headers, fatal=False, expected_status=(403, 404)) or {} |
276 | for download_data in original_response.get('download') or []: | |
605cad0b A |
277 | download_url = download_data.get('link') |
278 | if not download_url or download_data.get('quality') != 'source': | |
279 | continue | |
9cb070f9 | 280 | ext = determine_ext(parse_qs(download_url).get('filename', [''])[0].lower(), default_ext=None) |
281 | if not ext: | |
282 | urlh = self._request_webpage( | |
283 | HEADRequest(download_url), video_id, fatal=False, note='Determining source extension') | |
284 | ext = urlh and urlhandle_detect_ext(urlh) | |
605cad0b A |
285 | return { |
286 | 'url': download_url, | |
9cb070f9 | 287 | 'ext': ext or 'unknown_video', |
605cad0b A |
288 | 'format_id': download_data.get('public_name', 'Original'), |
289 | 'width': int_or_none(download_data.get('width')), | |
290 | 'height': int_or_none(download_data.get('height')), | |
291 | 'fps': int_or_none(download_data.get('fps')), | |
292 | 'filesize': int_or_none(download_data.get('size')), | |
293 | 'quality': 1, | |
294 | } | |
295 | ||
efb7e119 | 296 | |
65469a7f | 297 | class VimeoIE(VimeoBaseInfoExtractor): |
b3d14cbf PH |
298 | """Information extractor for vimeo.com.""" |
299 | ||
300 | # _VALID_URL matches Vimeo URLs | |
bbafbe20 | 301 | _VALID_URL = r'''(?x) |
74278def S |
302 | https?:// |
303 | (?: | |
304 | (?: | |
305 | www| | |
681ac7c9 | 306 | player |
74278def S |
307 | ) |
308 | \. | |
309 | )? | |
681ac7c9 | 310 | vimeo(?:pro)?\.com/ |
eb9c9c74 | 311 | (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/) |
2a6f8475 | 312 | (?:[^/]+/)*? |
74278def S |
313 | (?: |
314 | (?: | |
315 | play_redirect_hls| | |
316 | moogaloop\.swf)\?clip_id= | |
317 | )? | |
318 | (?:videos?/)? | |
319 | (?P<id>[0-9]+) | |
cce889b9 | 320 | (?:/(?P<unlisted_hash>[\da-f]{10}))? |
74278def S |
321 | /?(?:[?&].*)?(?:[#].*)?$ |
322 | ''' | |
9148eb00 | 323 | IE_NAME = 'vimeo' |
a91b954b JMF |
324 | _TESTS = [ |
325 | { | |
9148eb00 | 326 | 'url': 'http://vimeo.com/56015672#at=0', |
9148eb00 PH |
327 | 'md5': '8879b6cc097e987f02484baf890129e5', |
328 | 'info_dict': { | |
ad5976b4 PH |
329 | 'id': '56015672', |
330 | 'ext': 'mp4', | |
3867038a | 331 | 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550", |
681ac7c9 | 332 | 'description': 'md5:2d3305bad981a06ff79f027f19865021', |
c15cd296 | 333 | 'timestamp': 1355990239, |
68f3b61f | 334 | 'upload_date': '20121220', |
ec85ded8 | 335 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user7108434', |
68f3b61f S |
336 | 'uploader_id': 'user7108434', |
337 | 'uploader': 'Filippo Valsorda', | |
338 | 'duration': 10, | |
c38a67bc | 339 | 'license': 'by-sa', |
a91b954b | 340 | }, |
681ac7c9 RA |
341 | 'params': { |
342 | 'format': 'best[protocol=https]', | |
343 | }, | |
a91b954b JMF |
344 | }, |
345 | { | |
9148eb00 | 346 | 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876', |
9148eb00 PH |
347 | 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82', |
348 | 'note': 'Vimeo Pro video (#1197)', | |
349 | 'info_dict': { | |
4f3e9430 JMF |
350 | 'id': '68093876', |
351 | 'ext': 'mp4', | |
ec85ded8 | 352 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/openstreetmapus', |
9148eb00 PH |
353 | 'uploader_id': 'openstreetmapus', |
354 | 'uploader': 'OpenStreetMap US', | |
355 | 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography', | |
681ac7c9 | 356 | 'description': 'md5:2c362968038d4499f4d79f88458590c1', |
69c8fb9e | 357 | 'duration': 1595, |
681ac7c9 RA |
358 | 'upload_date': '20130610', |
359 | 'timestamp': 1370893156, | |
58ab5cbc | 360 | 'license': 'by', |
681ac7c9 RA |
361 | }, |
362 | 'params': { | |
363 | 'format': 'best[protocol=https]', | |
a91b954b JMF |
364 | }, |
365 | }, | |
aa32314d | 366 | { |
9148eb00 | 367 | 'url': 'http://player.vimeo.com/video/54469442', |
9148eb00 PH |
368 | 'md5': '619b811a4417aa4abe78dc653becf511', |
369 | 'note': 'Videos that embed the url in the player page', | |
370 | 'info_dict': { | |
4f3e9430 JMF |
371 | 'id': '54469442', |
372 | 'ext': 'mp4', | |
0e6ebc13 | 373 | 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012', |
cce889b9 | 374 | 'uploader': 'Business of Software', |
375 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/businessofsoftware', | |
376 | 'uploader_id': 'businessofsoftware', | |
69c8fb9e | 377 | 'duration': 3610, |
58ea7ec8 | 378 | 'description': None, |
aa32314d | 379 | }, |
681ac7c9 RA |
380 | 'params': { |
381 | 'format': 'best[protocol=https]', | |
382 | }, | |
93b22c78 JMF |
383 | }, |
384 | { | |
9148eb00 | 385 | 'url': 'http://vimeo.com/68375962', |
9148eb00 PH |
386 | 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7', |
387 | 'note': 'Video protected with password', | |
388 | 'info_dict': { | |
4f3e9430 JMF |
389 | 'id': '68375962', |
390 | 'ext': 'mp4', | |
3867038a | 391 | 'title': 'youtube-dl password protected test video', |
c15cd296 | 392 | 'timestamp': 1371200155, |
9148eb00 | 393 | 'upload_date': '20130614', |
ec85ded8 | 394 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128', |
9148eb00 PH |
395 | 'uploader_id': 'user18948128', |
396 | 'uploader': 'Jaime Marquínez Ferrándiz', | |
69c8fb9e | 397 | 'duration': 10, |
365d136b | 398 | 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f', |
93b22c78 | 399 | }, |
9148eb00 | 400 | 'params': { |
681ac7c9 | 401 | 'format': 'best[protocol=https]', |
3867038a | 402 | 'videopassword': 'youtube-dl', |
93b22c78 JMF |
403 | }, |
404 | }, | |
548f31d9 S |
405 | { |
406 | 'url': 'http://vimeo.com/channels/keypeele/75629013', | |
407 | 'md5': '2f86a05afe9d7abc0b9126d229bbe15d', | |
548f31d9 S |
408 | 'info_dict': { |
409 | 'id': '75629013', | |
410 | 'ext': 'mp4', | |
411 | 'title': 'Key & Peele: Terrorist Interrogation', | |
412 | 'description': 'md5:8678b246399b070816b12313e8b4eb5c', | |
ec85ded8 | 413 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio', |
548f31d9 S |
414 | 'uploader_id': 'atencio', |
415 | 'uploader': 'Peter Atencio', | |
d03beddf S |
416 | 'channel_id': 'keypeele', |
417 | 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/keypeele', | |
c15cd296 S |
418 | 'timestamp': 1380339469, |
419 | 'upload_date': '20130928', | |
548f31d9 S |
420 | 'duration': 187, |
421 | }, | |
9cb070f9 | 422 | 'params': {'format': 'http-1080p'}, |
548f31d9 | 423 | }, |
1eac553e S |
424 | { |
425 | 'url': 'http://vimeo.com/76979871', | |
1eac553e S |
426 | 'note': 'Video with subtitles', |
427 | 'info_dict': { | |
428 | 'id': '76979871', | |
429 | 'ext': 'mp4', | |
430 | 'title': 'The New Vimeo Player (You Know, For Videos)', | |
431 | 'description': 'md5:2ec900bf97c3f389378a96aee11260ea', | |
c15cd296 | 432 | 'timestamp': 1381846109, |
1eac553e | 433 | 'upload_date': '20131015', |
ec85ded8 | 434 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff', |
1eac553e S |
435 | 'uploader_id': 'staff', |
436 | 'uploader': 'Vimeo Staff', | |
69c8fb9e | 437 | 'duration': 62, |
58ab5cbc | 438 | 'subtitles': { |
439 | 'de': [{'ext': 'vtt'}], | |
440 | 'en': [{'ext': 'vtt'}], | |
441 | 'es': [{'ext': 'vtt'}], | |
442 | 'fr': [{'ext': 'vtt'}], | |
443 | }, | |
9cb070f9 | 444 | }, |
445 | 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'], | |
1eac553e | 446 | }, |
4698f0d8 JMF |
447 | { |
448 | # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/ | |
449 | 'url': 'https://player.vimeo.com/video/98044508', | |
450 | 'note': 'The js code contains assignments to the same variable as the config', | |
451 | 'info_dict': { | |
452 | 'id': '98044508', | |
453 | 'ext': 'mp4', | |
454 | 'title': 'Pier Solar OUYA Official Trailer', | |
455 | 'uploader': 'Tulio Gonçalves', | |
ec85ded8 | 456 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593', |
4698f0d8 JMF |
457 | 'uploader_id': 'user28849593', |
458 | }, | |
459 | }, | |
323f82a7 | 460 | { |
461 | # contains original format | |
462 | 'url': 'https://vimeo.com/33951933', | |
365d136b | 463 | 'md5': '53c688fa95a55bf4b7293d37a89c5c53', |
323f82a7 | 464 | 'info_dict': { |
465 | 'id': '33951933', | |
466 | 'ext': 'mp4', | |
467 | 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute', | |
468 | 'uploader': 'The DMCI', | |
ec85ded8 | 469 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci', |
323f82a7 | 470 | 'uploader_id': 'dmci', |
c15cd296 | 471 | 'timestamp': 1324343742, |
323f82a7 | 472 | 'upload_date': '20111220', |
473 | 'description': 'md5:ae23671e82d05415868f7ad1aec21147', | |
474 | }, | |
475 | }, | |
605cad0b A |
476 | { |
477 | 'note': 'Contains original format not accessible in webpage', | |
478 | 'url': 'https://vimeo.com/393756517', | |
479 | 'md5': 'c464af248b592190a5ffbb5d33f382b0', | |
480 | 'info_dict': { | |
481 | 'id': '393756517', | |
482 | 'ext': 'mov', | |
483 | 'timestamp': 1582642091, | |
484 | 'uploader_id': 'frameworkla', | |
485 | 'title': 'Straight To Hell - Sabrina: Netflix', | |
486 | 'uploader': 'Framework Studio', | |
487 | 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73', | |
488 | 'upload_date': '20200225', | |
489 | }, | |
605cad0b | 490 | }, |
c143ddce S |
491 | { |
492 | # only available via https://vimeo.com/channels/tributes/6213729 and | |
493 | # not via https://vimeo.com/6213729 | |
494 | 'url': 'https://vimeo.com/channels/tributes/6213729', | |
495 | 'info_dict': { | |
496 | 'id': '6213729', | |
d03beddf | 497 | 'ext': 'mp4', |
c143ddce S |
498 | 'title': 'Vimeo Tribute: The Shining', |
499 | 'uploader': 'Casey Donahue', | |
ec85ded8 | 500 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/caseydonahue', |
c143ddce | 501 | 'uploader_id': 'caseydonahue', |
d03beddf S |
502 | 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/tributes', |
503 | 'channel_id': 'tributes', | |
c15cd296 | 504 | 'timestamp': 1250886430, |
c143ddce S |
505 | 'upload_date': '20090821', |
506 | 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6', | |
507 | }, | |
508 | 'params': { | |
509 | 'skip_download': True, | |
510 | }, | |
c143ddce | 511 | }, |
f16f8505 | 512 | { |
cccd70a2 | 513 | # redirects to ondemand extractor and should be passed through it |
f16f8505 S |
514 | # for successful extraction |
515 | 'url': 'https://vimeo.com/73445910', | |
516 | 'info_dict': { | |
517 | 'id': '73445910', | |
518 | 'ext': 'mp4', | |
519 | 'title': 'The Reluctant Revolutionary', | |
520 | 'uploader': '10Ft Films', | |
ec85ded8 | 521 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/tenfootfilms', |
f16f8505 | 522 | 'uploader_id': 'tenfootfilms', |
681ac7c9 RA |
523 | 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384', |
524 | 'upload_date': '20130830', | |
525 | 'timestamp': 1377853339, | |
f16f8505 S |
526 | }, |
527 | 'params': { | |
528 | 'skip_download': True, | |
529 | }, | |
cce889b9 | 530 | 'skip': 'this page is no longer available.', |
f16f8505 | 531 | }, |
79fec976 RA |
532 | { |
533 | 'url': 'http://player.vimeo.com/video/68375962', | |
534 | 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7', | |
535 | 'info_dict': { | |
536 | 'id': '68375962', | |
537 | 'ext': 'mp4', | |
3867038a | 538 | 'title': 'youtube-dl password protected test video', |
79fec976 RA |
539 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128', |
540 | 'uploader_id': 'user18948128', | |
541 | 'uploader': 'Jaime Marquínez Ferrándiz', | |
542 | 'duration': 10, | |
543 | }, | |
544 | 'params': { | |
681ac7c9 | 545 | 'format': 'best[protocol=https]', |
3867038a | 546 | 'videopassword': 'youtube-dl', |
79fec976 RA |
547 | }, |
548 | }, | |
c143ddce S |
549 | { |
550 | 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741', | |
551 | 'only_matching': True, | |
552 | }, | |
8bea039b LL |
553 | { |
554 | 'url': 'https://vimeo.com/109815029', | |
555 | 'note': 'Video not completely processed, "failed" seed status', | |
556 | 'only_matching': True, | |
557 | }, | |
6b7ceee1 S |
558 | { |
559 | 'url': 'https://vimeo.com/groups/travelhd/videos/22439234', | |
560 | 'only_matching': True, | |
561 | }, | |
c8e3e097 S |
562 | { |
563 | 'url': 'https://vimeo.com/album/2632481/video/79010983', | |
564 | 'only_matching': True, | |
565 | }, | |
1f52a09e | 566 | { |
567 | 'url': 'https://vimeo.com/showcase/3253534/video/119195465', | |
568 | 'note': 'A video in a password protected album (showcase)', | |
569 | 'info_dict': { | |
570 | 'id': '119195465', | |
571 | 'ext': 'mp4', | |
572 | 'title': 'youtube-dl test video \'ä"BaW_jenozKc', | |
573 | 'uploader': 'Philipp Hagemeister', | |
574 | 'uploader_id': 'user20132939', | |
575 | 'description': 'md5:fa7b6c6d8db0bdc353893df2f111855b', | |
576 | 'upload_date': '20150209', | |
577 | 'timestamp': 1423518307, | |
578 | }, | |
579 | 'params': { | |
580 | 'format': 'best[protocol=https]', | |
581 | 'videopassword': 'youtube-dl', | |
582 | }, | |
583 | }, | |
16f1131a S |
584 | { |
585 | # source file returns 403: Forbidden | |
586 | 'url': 'https://vimeo.com/7809605', | |
587 | 'only_matching': True, | |
588 | }, | |
241a318f | 589 | { |
2a6f8475 | 590 | 'note': 'Direct URL with hash', |
241a318f | 591 | 'url': 'https://vimeo.com/160743502/abd0e13fb4', |
2a6f8475 | 592 | 'info_dict': { |
593 | 'id': '160743502', | |
594 | 'ext': 'mp4', | |
595 | 'uploader': 'Julian Tryba', | |
596 | 'uploader_id': 'aliniamedia', | |
597 | 'title': 'Harrisville New Hampshire', | |
598 | 'timestamp': 1459259666, | |
599 | 'upload_date': '20160329', | |
600 | }, | |
9cb070f9 | 601 | 'params': {'skip_download': True}, |
602 | }, | |
603 | { | |
604 | 'url': 'https://vimeo.com/138909882', | |
605 | 'info_dict': { | |
606 | 'id': '138909882', | |
607 | 'ext': 'mp4', | |
608 | 'title': 'Eastnor Castle 2015 Firework Champions - The Promo!', | |
609 | 'description': 'md5:5967e090768a831488f6e74b7821b3c1', | |
610 | 'uploader_id': 'fireworkchampions', | |
611 | 'uploader': 'Firework Champions', | |
612 | 'upload_date': '20150910', | |
613 | 'timestamp': 1441901895, | |
614 | }, | |
615 | 'params': { | |
616 | 'skip_download': True, | |
617 | 'format': 'Original', | |
618 | }, | |
bc2ca1bb | 619 | }, |
1ee34c76 | 620 | { |
621 | 'url': 'https://vimeo.com/channels/staffpicks/143603739', | |
622 | 'info_dict': { | |
623 | 'id': '143603739', | |
624 | 'ext': 'mp4', | |
625 | 'uploader': 'Karim Huu Do', | |
626 | 'timestamp': 1445846953, | |
627 | 'upload_date': '20151026', | |
628 | 'title': 'The Shoes - Submarine Feat. Blaine Harrison', | |
629 | 'uploader_id': 'karimhd', | |
630 | 'description': 'md5:8e2eea76de4504c2e8020a9bcfa1e843', | |
631 | }, | |
632 | 'params': {'skip_download': 'm3u8'}, | |
633 | }, | |
bc2ca1bb | 634 | { |
635 | # requires passing unlisted_hash(a52724358e) to load_download_config request | |
636 | 'url': 'https://vimeo.com/392479337/a52724358e', | |
637 | 'only_matching': True, | |
9cb070f9 | 638 | }, |
50e93e03 | 639 | { |
640 | # similar, but all numeric: ID must be 581039021, not 9603038895 | |
641 | # issue #29690 | |
642 | 'url': 'https://vimeo.com/581039021/9603038895', | |
643 | 'info_dict': { | |
644 | 'id': '581039021', | |
645 | # these have to be provided but we don't care | |
646 | 'ext': 'mp4', | |
647 | 'timestamp': 1627621014, | |
648 | 'title': 're:.+', | |
649 | 'uploader_id': 're:.+', | |
650 | 'uploader': 're:.+', | |
651 | 'upload_date': r're:\d+', | |
652 | }, | |
653 | 'params': { | |
654 | 'skip_download': True, | |
655 | }, | |
656 | } | |
a1a46075 S |
657 | # https://gettingthingsdone.com/workflowmap/ |
658 | # vimeo embed with check-password page protected by Referer header | |
a91b954b | 659 | ] |
b3d14cbf | 660 | |
d002e919 S |
661 | @staticmethod |
662 | def _smuggle_referrer(url, referrer_url): | |
663 | return smuggle_url(url, {'http_headers': {'Referer': referrer_url}}) | |
664 | ||
b407e173 | 665 | @staticmethod |
09b9c45e S |
666 | def _extract_urls(url, webpage): |
667 | urls = [] | |
b407e173 | 668 | # Look for embedded (iframe) Vimeo player |
09b9c45e | 669 | for mobj in re.finditer( |
7c1f4193 | 670 | r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/\d+.*?)\1', |
f475e881 | 671 | webpage): |
09b9c45e S |
672 | urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url')), url)) |
673 | PLAIN_EMBED_RE = ( | |
674 | # Look for embedded (swf embed) Vimeo player | |
675 | r'<embed[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1', | |
676 | # Look more for non-standard embedded Vimeo player | |
677 | r'<video[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)\1', | |
678 | ) | |
679 | for embed_re in PLAIN_EMBED_RE: | |
680 | for mobj in re.finditer(embed_re, webpage): | |
681 | urls.append(mobj.group('url')) | |
682 | return urls | |
683 | ||
684 | @staticmethod | |
685 | def _extract_url(url, webpage): | |
686 | urls = VimeoIE._extract_urls(url, webpage) | |
687 | return urls[0] if urls else None | |
b407e173 | 688 | |
a1a46075 | 689 | def _verify_player_video_password(self, url, video_id, headers): |
cce889b9 | 690 | password = self._get_video_password() |
79fec976 RA |
691 | data = urlencode_postdata({ |
692 | 'password': base64.b64encode(password.encode()), | |
693 | }) | |
a1a46075 S |
694 | headers = merge_dicts(headers, { |
695 | 'Content-Type': 'application/x-www-form-urlencoded', | |
696 | }) | |
697 | checked = self._download_json( | |
698 | url + '/check-password', video_id, | |
699 | 'Verifying the password', data=data, headers=headers) | |
700 | if checked is False: | |
701 | raise ExtractorError('Wrong video password', expected=True) | |
702 | return checked | |
0eecc6a4 | 703 | |
fc79158d JMF |
704 | def _real_initialize(self): |
705 | self._login() | |
706 | ||
58ab5cbc | 707 | def _extract_from_api(self, video_id, unlisted_hash=None): |
708 | token = self._download_json( | |
709 | 'https://vimeo.com/_rv/jwt', video_id, headers={ | |
710 | 'X-Requested-With': 'XMLHttpRequest' | |
711 | })['token'] | |
712 | api_url = 'https://api.vimeo.com/videos/' + video_id | |
713 | if unlisted_hash: | |
714 | api_url += ':' + unlisted_hash | |
715 | video = self._download_json( | |
716 | api_url, video_id, headers={ | |
717 | 'Authorization': 'jwt ' + token, | |
718 | }, query={ | |
719 | 'fields': 'config_url,created_time,description,license,metadata.connections.comments.total,metadata.connections.likes.total,release_time,stats.plays', | |
720 | }) | |
721 | info = self._parse_config(self._download_json( | |
722 | video['config_url'], video_id), video_id) | |
723 | self._vimeo_sort_formats(info['formats']) | |
724 | get_timestamp = lambda x: parse_iso8601(video.get(x + '_time')) | |
725 | info.update({ | |
726 | 'description': video.get('description'), | |
727 | 'license': video.get('license'), | |
728 | 'release_timestamp': get_timestamp('release'), | |
729 | 'timestamp': get_timestamp('created'), | |
730 | 'view_count': int_or_none(try_get(video, lambda x: x['stats']['plays'])), | |
731 | }) | |
732 | connections = try_get( | |
733 | video, lambda x: x['metadata']['connections'], dict) or {} | |
734 | for k in ('comment', 'like'): | |
735 | info[k + '_count'] = int_or_none(try_get(connections, lambda x: x[k + 's']['total'])) | |
736 | return info | |
737 | ||
1f52a09e | 738 | def _try_album_password(self, url): |
739 | album_id = self._search_regex( | |
740 | r'vimeo\.com/(?:album|showcase)/([^/]+)', url, 'album id', default=None) | |
741 | if not album_id: | |
742 | return | |
743 | viewer = self._download_json( | |
744 | 'https://vimeo.com/_rv/viewer', album_id, fatal=False) | |
745 | if not viewer: | |
746 | webpage = self._download_webpage(url, album_id) | |
747 | viewer = self._parse_json(self._search_regex( | |
748 | r'bootstrap_data\s*=\s*({.+?})</script>', | |
749 | webpage, 'bootstrap data'), album_id)['viewer'] | |
750 | jwt = viewer['jwt'] | |
751 | album = self._download_json( | |
752 | 'https://api.vimeo.com/albums/' + album_id, | |
753 | album_id, headers={'Authorization': 'jwt ' + jwt}, | |
754 | query={'fields': 'description,name,privacy'}) | |
755 | if try_get(album, lambda x: x['privacy']['view']) == 'password': | |
a06916d9 | 756 | password = self.get_param('videopassword') |
1f52a09e | 757 | if not password: |
758 | raise ExtractorError( | |
759 | 'This album is protected by a password, use the --video-password option', | |
760 | expected=True) | |
761 | self._set_vimeo_cookie('vuid', viewer['vuid']) | |
762 | try: | |
763 | self._download_json( | |
764 | 'https://vimeo.com/showcase/%s/auth' % album_id, | |
765 | album_id, 'Verifying the password', data=urlencode_postdata({ | |
766 | 'password': password, | |
767 | 'token': viewer['xsrft'], | |
768 | }), headers={ | |
769 | 'X-Requested-With': 'XMLHttpRequest', | |
770 | }) | |
771 | except ExtractorError as e: | |
772 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401: | |
773 | raise ExtractorError('Wrong password', expected=True) | |
774 | raise | |
775 | ||
a0088bdf | 776 | def _real_extract(self, url): |
5dbe81a1 | 777 | url, data = unsmuggle_url(url, {}) |
8b7539d2 | 778 | headers = self.get_param('http_headers').copy() |
5dbe81a1 | 779 | if 'http_headers' in data: |
5dbe81a1 | 780 | headers.update(data['http_headers']) |
ba5d51b3 PH |
781 | if 'Referer' not in headers: |
782 | headers['Referer'] = url | |
9d4660ca | 783 | |
b3d14cbf | 784 | # Extract ID from URL |
2a6f8475 | 785 | mobj = self._match_valid_url(url).groupdict() |
786 | video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash') | |
cce889b9 | 787 | if unlisted_hash: |
58ab5cbc | 788 | return self._extract_from_api(video_id, unlisted_hash) |
cce889b9 | 789 | |
58ea7ec8 | 790 | orig_url = url |
681ac7c9 | 791 | is_pro = 'vimeopro.com/' in url |
681ac7c9 | 792 | if is_pro: |
06242d44 | 793 | # some videos require portfolio_id to be present in player url |
067aa17e | 794 | # https://github.com/ytdl-org/youtube-dl/issues/20070 |
06242d44 | 795 | url = self._extract_url(url, self._download_webpage(url, video_id)) |
681ac7c9 RA |
796 | if not url: |
797 | url = 'https://vimeo.com/' + video_id | |
40b6495d | 798 | elif any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')): |
10831b5e | 799 | url = 'https://vimeo.com/' + video_id |
b3d14cbf | 800 | |
1f52a09e | 801 | self._try_album_password(url) |
1060425c | 802 | try: |
681ac7c9 RA |
803 | # Retrieve video webpage to extract further information |
804 | webpage, urlh = self._download_webpage_handle( | |
805 | url, video_id, headers=headers) | |
7947a1f7 | 806 | redirect_url = urlh.geturl() |
1060425c PH |
807 | except ExtractorError as ee: |
808 | if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403: | |
809 | errmsg = ee.cause.read() | |
810 | if b'Because of its privacy settings, this video cannot be played here' in errmsg: | |
811 | raise ExtractorError( | |
812 | 'Cannot download embed-only video without embedding ' | |
7a5c1cfe | 813 | 'URL. Please call yt-dlp with the URL of the page ' |
1060425c PH |
814 | 'that embeds this video.', |
815 | expected=True) | |
816 | raise | |
b3d14cbf | 817 | |
58ab5cbc | 818 | if '://player.vimeo.com/video/' in url: |
819 | config = self._parse_json(self._search_regex( | |
820 | r'\bconfig\s*=\s*({.+?})\s*;', webpage, 'info section'), video_id) | |
821 | if config.get('view') == 4: | |
822 | config = self._verify_player_video_password( | |
823 | redirect_url, video_id, headers) | |
824 | info = self._parse_config(config, video_id) | |
825 | self._vimeo_sort_formats(info['formats']) | |
826 | return info | |
827 | ||
828 | if re.search(r'<form[^>]+?id="pw_form"', webpage): | |
829 | video_password = self._get_video_password() | |
830 | token, vuid = self._extract_xsrft_and_vuid(webpage) | |
831 | webpage = self._verify_video_password( | |
832 | redirect_url, video_id, video_password, token, vuid) | |
b3d14cbf | 833 | |
eb9c9c74 | 834 | vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None) |
998e6cdb | 835 | if vimeo_config: |
58ab5cbc | 836 | seed_status = vimeo_config.get('seed_status') or {} |
998e6cdb S |
837 | if seed_status.get('state') == 'failed': |
838 | raise ExtractorError( | |
b6aa99af | 839 | '%s said: %s' % (self.IE_NAME, seed_status['title']), |
998e6cdb S |
840 | expected=True) |
841 | ||
c38a67bc | 842 | cc_license = None |
c15cd296 | 843 | timestamp = None |
681ac7c9 | 844 | video_description = None |
58ab5cbc | 845 | info_dict = {} |
1ee34c76 | 846 | config_url = None |
c38a67bc | 847 | |
58ab5cbc | 848 | channel_id = self._search_regex( |
849 | r'vimeo\.com/channels/([^/]+)', url, 'channel id', default=None) | |
850 | if channel_id: | |
851 | config_url = self._html_search_regex( | |
1ee34c76 | 852 | r'\bdata-config-url="([^"]+)"', webpage, 'config URL', default=None) |
58ab5cbc | 853 | video_description = clean_html(get_element_by_class('description', webpage)) |
854 | info_dict.update({ | |
855 | 'channel_id': channel_id, | |
856 | 'channel_url': 'https://vimeo.com/channels/' + channel_id, | |
857 | }) | |
1ee34c76 | 858 | if not config_url: |
58ab5cbc | 859 | page_config = self._parse_json(self._search_regex( |
860 | r'vimeo\.(?:clip|vod_title)_page_config\s*=\s*({.+?});', | |
861 | webpage, 'page config', default='{}'), video_id, fatal=False) | |
862 | if not page_config: | |
863 | return self._extract_from_api(video_id) | |
864 | config_url = page_config['player']['config_url'] | |
865 | cc_license = page_config.get('cc_license') | |
866 | clip = page_config.get('clip') or {} | |
867 | timestamp = clip.get('uploaded_on') | |
868 | video_description = clean_html( | |
869 | clip.get('description') or page_config.get('description_html_escaped')) | |
870 | config = self._download_json(config_url, video_id) | |
bc2ca1bb | 871 | video = config.get('video') or {} |
872 | vod = video.get('vod') or {} | |
8b40c927 | 873 | |
6a55bb66 S |
874 | def is_rented(): |
875 | if '>You rented this title.<' in webpage: | |
876 | return True | |
58ab5cbc | 877 | if try_get(config, lambda x: x['user']['purchased']): |
6a55bb66 | 878 | return True |
58ab5cbc | 879 | for purchase_option in (vod.get('purchase_options') or []): |
8b40c927 RA |
880 | if purchase_option.get('purchased'): |
881 | return True | |
882 | label = purchase_option.get('label_string') | |
883 | if label and (label.startswith('You rented this') or label.endswith(' remaining')): | |
884 | return True | |
6a55bb66 S |
885 | return False |
886 | ||
8b40c927 RA |
887 | if is_rented() and vod.get('is_trailer'): |
888 | feature_id = vod.get('feature_id') | |
5dbe81a1 S |
889 | if feature_id and not data.get('force_feature_id', False): |
890 | return self.url_result(smuggle_url( | |
891 | 'https://player.vimeo.com/player/%s' % feature_id, | |
892 | {'force_feature_id': True}), 'Vimeo') | |
893 | ||
681ac7c9 RA |
894 | if not video_description: |
895 | video_description = self._html_search_regex( | |
896 | r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>', | |
897 | webpage, 'description', default=None) | |
58ea7ec8 PH |
898 | if not video_description: |
899 | video_description = self._html_search_meta( | |
58ab5cbc | 900 | ['description', 'og:description', 'twitter:description'], |
901 | webpage, default=None) | |
681ac7c9 | 902 | if not video_description and is_pro: |
58ea7ec8 PH |
903 | orig_webpage = self._download_webpage( |
904 | orig_url, video_id, | |
905 | note='Downloading webpage for description', | |
906 | fatal=False) | |
907 | if orig_webpage: | |
908 | video_description = self._html_search_meta( | |
909 | 'description', orig_webpage, default=None) | |
58ab5cbc | 910 | if not video_description: |
6a39ee13 | 911 | self.report_warning('Cannot find video description') |
b3d14cbf | 912 | |
c15cd296 S |
913 | if not timestamp: |
914 | timestamp = self._search_regex( | |
915 | r'<time[^>]+datetime="([^"]+)"', webpage, | |
916 | 'timestamp', default=None) | |
b3d14cbf | 917 | |
58ab5cbc | 918 | view_count = int_or_none(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count', default=None)) |
919 | like_count = int_or_none(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count', default=None)) | |
920 | comment_count = int_or_none(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count', default=None)) | |
4e761794 | 921 | |
a6387bfd | 922 | formats = [] |
27655037 RA |
923 | |
924 | source_format = self._extract_original_format( | |
bc2ca1bb | 925 | 'https://vimeo.com/' + video_id, video_id, video.get('unlisted_hash')) |
27655037 RA |
926 | if source_format: |
927 | formats.append(source_format) | |
1eac553e | 928 | |
ae1c585c S |
929 | info_dict_config = self._parse_config(config, video_id) |
930 | formats.extend(info_dict_config['formats']) | |
531a7496 | 931 | self._vimeo_sort_formats(formats) |
c38a67bc | 932 | |
ae1c585c S |
933 | json_ld = self._search_json_ld(webpage, video_id, default={}) |
934 | ||
c38a67bc S |
935 | if not cc_license: |
936 | cc_license = self._search_regex( | |
937 | r'<link[^>]+rel=["\']license["\'][^>]+href=(["\'])(?P<license>(?:(?!\1).)+)\1', | |
938 | webpage, 'license', default=None, group='license') | |
939 | ||
58ab5cbc | 940 | info_dict.update({ |
531a7496 | 941 | 'formats': formats, |
c15cd296 | 942 | 'timestamp': unified_timestamp(timestamp), |
b0268cb6 | 943 | 'description': video_description, |
9103bbc5 | 944 | 'webpage_url': url, |
4e761794 JMF |
945 | 'view_count': view_count, |
946 | 'like_count': like_count, | |
947 | 'comment_count': comment_count, | |
c38a67bc | 948 | 'license': cc_license, |
58ab5cbc | 949 | }) |
531a7496 | 950 | |
58ab5cbc | 951 | return merge_dicts(info_dict, info_dict_config, json_ld) |
caeefc29 JMF |
952 | |
953 | ||
681ac7c9 | 954 | class VimeoOndemandIE(VimeoIE): |
1e501364 | 955 | IE_NAME = 'vimeo:ondemand' |
58ab5cbc | 956 | _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?:[^/]+/)?(?P<id>[^/?#&]+)' |
74278def S |
957 | _TESTS = [{ |
958 | # ondemand video not available via https://vimeo.com/id | |
959 | 'url': 'https://vimeo.com/ondemand/20704', | |
960 | 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35', | |
961 | 'info_dict': { | |
962 | 'id': '105442900', | |
963 | 'ext': 'mp4', | |
964 | 'title': 'המעבדה - במאי יותם פלדמן', | |
965 | 'uploader': 'גם סרטים', | |
ec85ded8 | 966 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms', |
74278def | 967 | 'uploader_id': 'gumfilms', |
681ac7c9 RA |
968 | 'description': 'md5:4c027c965e439de4baab621e48b60791', |
969 | 'upload_date': '20140906', | |
970 | 'timestamp': 1410032453, | |
74278def | 971 | }, |
1fd0fc42 S |
972 | 'params': { |
973 | 'format': 'best[protocol=https]', | |
974 | }, | |
681ac7c9 | 975 | 'expected_warnings': ['Unable to download JSON metadata'], |
d002e919 S |
976 | }, { |
977 | # requires Referer to be passed along with og:video:url | |
978 | 'url': 'https://vimeo.com/ondemand/36938/126682985', | |
979 | 'info_dict': { | |
681ac7c9 | 980 | 'id': '126584684', |
d002e919 S |
981 | 'ext': 'mp4', |
982 | 'title': 'Rävlock, rätt läte på rätt plats', | |
983 | 'uploader': 'Lindroth & Norin', | |
681ac7c9 RA |
984 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/lindrothnorin', |
985 | 'uploader_id': 'lindrothnorin', | |
986 | 'description': 'md5:c3c46a90529612c8279fb6af803fc0df', | |
987 | 'upload_date': '20150502', | |
988 | 'timestamp': 1430586422, | |
d002e919 S |
989 | }, |
990 | 'params': { | |
991 | 'skip_download': True, | |
992 | }, | |
681ac7c9 | 993 | 'expected_warnings': ['Unable to download JSON metadata'], |
74278def S |
994 | }, { |
995 | 'url': 'https://vimeo.com/ondemand/nazmaalik', | |
996 | 'only_matching': True, | |
997 | }, { | |
998 | 'url': 'https://vimeo.com/ondemand/141692381', | |
999 | 'only_matching': True, | |
1000 | }, { | |
1001 | 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832', | |
1002 | 'only_matching': True, | |
1003 | }] | |
1004 | ||
74278def | 1005 | |
f6c3664d | 1006 | class VimeoChannelIE(VimeoBaseInfoExtractor): |
9148eb00 | 1007 | IE_NAME = 'vimeo:channel' |
3946864c | 1008 | _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])' |
caeefc29 | 1009 | _MORE_PAGES_INDICATOR = r'<a.+?rel="next"' |
84458766 | 1010 | _TITLE = None |
55a10eab | 1011 | _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"' |
2929b3e7 | 1012 | _TESTS = [{ |
3946864c | 1013 | 'url': 'https://vimeo.com/channels/tributes', |
2929b3e7 | 1014 | 'info_dict': { |
a3fa5da4 | 1015 | 'id': 'tributes', |
2929b3e7 PH |
1016 | 'title': 'Vimeo Tributes', |
1017 | }, | |
1018 | 'playlist_mincount': 25, | |
1019 | }] | |
681ac7c9 | 1020 | _BASE_URL_TEMPL = 'https://vimeo.com/channels/%s' |
caeefc29 | 1021 | |
5cc14c2f JMF |
1022 | def _page_url(self, base_url, pagenum): |
1023 | return '%s/videos/page:%d/' % (base_url, pagenum) | |
1024 | ||
fb30ec22 | 1025 | def _extract_list_title(self, webpage): |
2605043d S |
1026 | return self._TITLE or self._html_search_regex( |
1027 | self._TITLE_RE, webpage, 'list title', fatal=False) | |
fb30ec22 | 1028 | |
2c94198e | 1029 | def _title_and_entries(self, list_id, base_url): |
caeefc29 | 1030 | for pagenum in itertools.count(1): |
bf8f082a | 1031 | page_url = self._page_url(base_url, pagenum) |
55a10eab | 1032 | webpage = self._download_webpage( |
bf8f082a | 1033 | page_url, list_id, |
9148eb00 | 1034 | 'Downloading page %s' % pagenum) |
bf8f082a PH |
1035 | |
1036 | if pagenum == 1: | |
2c94198e S |
1037 | yield self._extract_list_title(webpage) |
1038 | ||
c8e3e097 S |
1039 | # Try extracting href first since not all videos are available via |
1040 | # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729) | |
1041 | clips = re.findall( | |
04a3d4d2 | 1042 | r'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage) |
c8e3e097 | 1043 | if clips: |
04a3d4d2 | 1044 | for video_id, video_url, video_title in clips: |
c8e3e097 S |
1045 | yield self.url_result( |
1046 | compat_urlparse.urljoin(base_url, video_url), | |
04a3d4d2 | 1047 | VimeoIE.ie_key(), video_id=video_id, video_title=video_title) |
c8e3e097 S |
1048 | # More relaxed fallback |
1049 | else: | |
1050 | for video_id in re.findall(r'id=["\']clip_(\d+)', webpage): | |
1051 | yield self.url_result( | |
1052 | 'https://vimeo.com/%s' % video_id, | |
1053 | VimeoIE.ie_key(), video_id=video_id) | |
bf8f082a | 1054 | |
caeefc29 JMF |
1055 | if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None: |
1056 | break | |
1057 | ||
2c94198e S |
1058 | def _extract_videos(self, list_id, base_url): |
1059 | title_and_entries = self._title_and_entries(list_id, base_url) | |
1060 | list_title = next(title_and_entries) | |
1061 | return self.playlist_result(title_and_entries, list_id, list_title) | |
55a10eab JMF |
1062 | |
1063 | def _real_extract(self, url): | |
681ac7c9 RA |
1064 | channel_id = self._match_id(url) |
1065 | return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id) | |
55a10eab JMF |
1066 | |
1067 | ||
1068 | class VimeoUserIE(VimeoChannelIE): | |
9148eb00 | 1069 | IE_NAME = 'vimeo:user' |
681ac7c9 | 1070 | _VALID_URL = r'https://vimeo\.com/(?!(?:[0-9]+|watchlater)(?:$|[?#/]))(?P<id>[^/]+)(?:/videos|[#?]|$)' |
55a10eab | 1071 | _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>' |
2929b3e7 | 1072 | _TESTS = [{ |
3946864c | 1073 | 'url': 'https://vimeo.com/nkistudio/videos', |
2929b3e7 PH |
1074 | 'info_dict': { |
1075 | 'title': 'Nki', | |
a3fa5da4 | 1076 | 'id': 'nkistudio', |
2929b3e7 PH |
1077 | }, |
1078 | 'playlist_mincount': 66, | |
1079 | }] | |
681ac7c9 | 1080 | _BASE_URL_TEMPL = 'https://vimeo.com/%s' |
5cc14c2f JMF |
1081 | |
1082 | ||
51c7f40c | 1083 | class VimeoAlbumIE(VimeoBaseInfoExtractor): |
9148eb00 | 1084 | IE_NAME = 'vimeo:album' |
eb9c9c74 | 1085 | _VALID_URL = r'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))' |
5cc14c2f | 1086 | _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>' |
2929b3e7 | 1087 | _TESTS = [{ |
d1508cd6 | 1088 | 'url': 'https://vimeo.com/album/2632481', |
2929b3e7 | 1089 | 'info_dict': { |
a3fa5da4 | 1090 | 'id': '2632481', |
2929b3e7 PH |
1091 | 'title': 'Staff Favorites: November 2013', |
1092 | }, | |
1093 | 'playlist_mincount': 13, | |
bf8f082a PH |
1094 | }, { |
1095 | 'note': 'Password-protected album', | |
1096 | 'url': 'https://vimeo.com/album/3253534', | |
1097 | 'info_dict': { | |
1098 | 'title': 'test', | |
1099 | 'id': '3253534', | |
1100 | }, | |
1101 | 'playlist_count': 1, | |
1102 | 'params': { | |
3867038a | 1103 | 'videopassword': 'youtube-dl', |
bf8f082a | 1104 | } |
2929b3e7 | 1105 | }] |
eb9c9c74 RA |
1106 | _PAGE_SIZE = 100 |
1107 | ||
a0566bbf | 1108 | def _fetch_page(self, album_id, authorization, hashed_pass, page): |
eb9c9c74 RA |
1109 | api_page = page + 1 |
1110 | query = { | |
974311b5 | 1111 | 'fields': 'link,uri', |
eb9c9c74 RA |
1112 | 'page': api_page, |
1113 | 'per_page': self._PAGE_SIZE, | |
1114 | } | |
1115 | if hashed_pass: | |
1116 | query['_hashed_pass'] = hashed_pass | |
421a4595 | 1117 | try: |
1118 | videos = self._download_json( | |
1119 | 'https://api.vimeo.com/albums/%s/videos' % album_id, | |
1120 | album_id, 'Downloading page %d' % api_page, query=query, headers={ | |
1121 | 'Authorization': 'jwt ' + authorization, | |
1122 | })['data'] | |
1123 | except ExtractorError as e: | |
1124 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400: | |
1125 | return | |
eb9c9c74 RA |
1126 | for video in videos: |
1127 | link = video.get('link') | |
1128 | if not link: | |
1129 | continue | |
974311b5 RA |
1130 | uri = video.get('uri') |
1131 | video_id = self._search_regex(r'/videos/(\d+)', uri, 'video_id', default=None) if uri else None | |
1132 | yield self.url_result(link, VimeoIE.ie_key(), video_id) | |
5cc14c2f JMF |
1133 | |
1134 | def _real_extract(self, url): | |
bf8f082a | 1135 | album_id = self._match_id(url) |
8bdd16b4 | 1136 | viewer = self._download_json( |
1137 | 'https://vimeo.com/_rv/viewer', album_id, fatal=False) | |
1138 | if not viewer: | |
1139 | webpage = self._download_webpage(url, album_id) | |
1140 | viewer = self._parse_json(self._search_regex( | |
1141 | r'bootstrap_data\s*=\s*({.+?})</script>', | |
1142 | webpage, 'bootstrap data'), album_id)['viewer'] | |
51c7f40c RA |
1143 | jwt = viewer['jwt'] |
1144 | album = self._download_json( | |
1145 | 'https://api.vimeo.com/albums/' + album_id, | |
1146 | album_id, headers={'Authorization': 'jwt ' + jwt}, | |
1147 | query={'fields': 'description,name,privacy'}) | |
1148 | hashed_pass = None | |
1149 | if try_get(album, lambda x: x['privacy']['view']) == 'password': | |
a06916d9 | 1150 | password = self.get_param('videopassword') |
51c7f40c RA |
1151 | if not password: |
1152 | raise ExtractorError( | |
1153 | 'This album is protected by a password, use the --video-password option', | |
1154 | expected=True) | |
1155 | self._set_vimeo_cookie('vuid', viewer['vuid']) | |
1156 | try: | |
1157 | hashed_pass = self._download_json( | |
1158 | 'https://vimeo.com/showcase/%s/auth' % album_id, | |
1159 | album_id, 'Verifying the password', data=urlencode_postdata({ | |
1160 | 'password': password, | |
1161 | 'token': viewer['xsrft'], | |
1162 | }), headers={ | |
1163 | 'X-Requested-With': 'XMLHttpRequest', | |
1164 | })['hashed_pass'] | |
1165 | except ExtractorError as e: | |
1166 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401: | |
1167 | raise ExtractorError('Wrong password', expected=True) | |
1168 | raise | |
eb9c9c74 | 1169 | entries = OnDemandPagedList(functools.partial( |
51c7f40c RA |
1170 | self._fetch_page, album_id, jwt, hashed_pass), self._PAGE_SIZE) |
1171 | return self.playlist_result( | |
1172 | entries, album_id, album.get('name'), album.get('description')) | |
fb30ec22 JMF |
1173 | |
1174 | ||
681ac7c9 | 1175 | class VimeoGroupsIE(VimeoChannelIE): |
9148eb00 | 1176 | IE_NAME = 'vimeo:group' |
681ac7c9 | 1177 | _VALID_URL = r'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)' |
2929b3e7 | 1178 | _TESTS = [{ |
9cb070f9 | 1179 | 'url': 'https://vimeo.com/groups/meetup', |
2929b3e7 | 1180 | 'info_dict': { |
9cb070f9 | 1181 | 'id': 'meetup', |
1182 | 'title': 'Vimeo Meetup!', | |
2929b3e7 | 1183 | }, |
681ac7c9 | 1184 | 'playlist_mincount': 27, |
2929b3e7 | 1185 | }] |
681ac7c9 | 1186 | _BASE_URL_TEMPL = 'https://vimeo.com/groups/%s' |
fcea44c6 PH |
1187 | |
1188 | ||
531a7496 | 1189 | class VimeoReviewIE(VimeoBaseInfoExtractor): |
9148eb00 PH |
1190 | IE_NAME = 'vimeo:review' |
1191 | IE_DESC = 'Review pages on vimeo' | |
27655037 | 1192 | _VALID_URL = r'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})' |
d36d3f42 | 1193 | _TESTS = [{ |
fcea44c6 | 1194 | 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d', |
fcea44c6 PH |
1195 | 'md5': 'c507a72f780cacc12b2248bb4006d253', |
1196 | 'info_dict': { | |
fc09240e PH |
1197 | 'id': '75524534', |
1198 | 'ext': 'mp4', | |
fcea44c6 PH |
1199 | 'title': "DICK HARDWICK 'Comedian'", |
1200 | 'uploader': 'Richard Hardwick', | |
531a7496 | 1201 | 'uploader_id': 'user21297594', |
681ac7c9 RA |
1202 | 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks", |
1203 | }, | |
d36d3f42 PH |
1204 | }, { |
1205 | 'note': 'video player needs Referer', | |
3946864c | 1206 | 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053', |
d36d3f42 PH |
1207 | 'md5': '6295fdab8f4bf6a002d058b2c6dce276', |
1208 | 'info_dict': { | |
1209 | 'id': '91613211', | |
1210 | 'ext': 'mp4', | |
9dec9930 | 1211 | 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn', |
d36d3f42 PH |
1212 | 'uploader': 'DevWeek Events', |
1213 | 'duration': 2773, | |
ec85ded8 | 1214 | 'thumbnail': r're:^https?://.*\.jpg$', |
531a7496 | 1215 | 'uploader_id': 'user22258446', |
681ac7c9 RA |
1216 | }, |
1217 | 'skip': 'video gone', | |
c1ff6e1a YCH |
1218 | }, { |
1219 | 'note': 'Password protected', | |
1220 | 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde', | |
1221 | 'info_dict': { | |
1222 | 'id': '138823582', | |
1223 | 'ext': 'mp4', | |
1224 | 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1', | |
1225 | 'uploader': 'TMB', | |
1226 | 'uploader_id': 'user37284429', | |
1227 | }, | |
1228 | 'params': { | |
1229 | 'videopassword': 'holygrail', | |
1230 | }, | |
a093cfc7 | 1231 | 'skip': 'video gone', |
d36d3f42 | 1232 | }] |
fcea44c6 | 1233 | |
c1ff6e1a YCH |
1234 | def _real_initialize(self): |
1235 | self._login() | |
1236 | ||
fcea44c6 | 1237 | def _real_extract(self, url): |
5ad28e7f | 1238 | page_url, video_id = self._match_valid_url(url).groups() |
cce889b9 | 1239 | data = self._download_json( |
1240 | page_url.replace('/review/', '/review/data/'), video_id) | |
1241 | if data.get('isLocked') is True: | |
1242 | video_password = self._get_video_password() | |
1243 | viewer = self._download_json( | |
1244 | 'https://vimeo.com/_rv/viewer', video_id) | |
1245 | webpage = self._verify_video_password( | |
1246 | 'https://vimeo.com/' + video_id, video_id, | |
1247 | video_password, viewer['xsrft'], viewer['vuid']) | |
1248 | clip_page_config = self._parse_json(self._search_regex( | |
1249 | r'window\.vimeo\.clip_page_config\s*=\s*({.+?});', | |
1250 | webpage, 'clip page config'), video_id) | |
1251 | config_url = clip_page_config['player']['config_url'] | |
1252 | clip_data = clip_page_config.get('clip') or {} | |
1253 | else: | |
1254 | clip_data = data['clipData'] | |
1255 | config_url = clip_data['configUrl'] | |
c1ff6e1a | 1256 | config = self._download_json(config_url, video_id) |
531a7496 | 1257 | info_dict = self._parse_config(config, video_id) |
681ac7c9 RA |
1258 | source_format = self._extract_original_format( |
1259 | page_url + '/action', video_id) | |
27655037 RA |
1260 | if source_format: |
1261 | info_dict['formats'].append(source_format) | |
531a7496 | 1262 | self._vimeo_sort_formats(info_dict['formats']) |
681ac7c9 | 1263 | info_dict['description'] = clean_html(clip_data.get('description')) |
531a7496 | 1264 | return info_dict |
efb7e119 JMF |
1265 | |
1266 | ||
f6c3664d | 1267 | class VimeoWatchLaterIE(VimeoChannelIE): |
efb7e119 JMF |
1268 | IE_NAME = 'vimeo:watchlater' |
1269 | IE_DESC = 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)' | |
84458766 S |
1270 | _VALID_URL = r'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater' |
1271 | _TITLE = 'Watch Later' | |
efb7e119 | 1272 | _LOGIN_REQUIRED = True |
2929b3e7 | 1273 | _TESTS = [{ |
84458766 | 1274 | 'url': 'https://vimeo.com/watchlater', |
2929b3e7 PH |
1275 | 'only_matching': True, |
1276 | }] | |
efb7e119 JMF |
1277 | |
1278 | def _real_initialize(self): | |
1279 | self._login() | |
1280 | ||
1281 | def _page_url(self, base_url, pagenum): | |
1282 | url = '%s/page:%d/' % (base_url, pagenum) | |
67dda517 | 1283 | request = sanitized_Request(url) |
efb7e119 JMF |
1284 | # Set the header to get a partial html page with the ids, |
1285 | # the normal page doesn't contain them. | |
1286 | request.add_header('X-Requested-With', 'XMLHttpRequest') | |
1287 | return request | |
1288 | ||
1289 | def _real_extract(self, url): | |
84458766 | 1290 | return self._extract_videos('watchlater', 'https://vimeo.com/watchlater') |
d6e6a422 PH |
1291 | |
1292 | ||
091c9b43 | 1293 | class VimeoLikesIE(VimeoChannelIE): |
361a965b | 1294 | _VALID_URL = r'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)' |
d6e6a422 PH |
1295 | IE_NAME = 'vimeo:likes' |
1296 | IE_DESC = 'Vimeo user likes' | |
361a965b | 1297 | _TESTS = [{ |
9c44d242 PH |
1298 | 'url': 'https://vimeo.com/user755559/likes/', |
1299 | 'playlist_mincount': 293, | |
611c1dd9 | 1300 | 'info_dict': { |
091c9b43 S |
1301 | 'id': 'user755559', |
1302 | 'title': 'urza’s Likes', | |
d6e6a422 | 1303 | }, |
361a965b S |
1304 | }, { |
1305 | 'url': 'https://vimeo.com/stormlapse/likes', | |
1306 | 'only_matching': True, | |
1307 | }] | |
d6e6a422 | 1308 | |
091c9b43 S |
1309 | def _page_url(self, base_url, pagenum): |
1310 | return '%s/page:%d/' % (base_url, pagenum) | |
1311 | ||
d6e6a422 PH |
1312 | def _real_extract(self, url): |
1313 | user_id = self._match_id(url) | |
091c9b43 | 1314 | return self._extract_videos(user_id, 'https://vimeo.com/%s/likes' % user_id) |
ca01d178 RA |
1315 | |
1316 | ||
a1ee23e9 | 1317 | class VHXEmbedIE(VimeoBaseInfoExtractor): |
ca01d178 RA |
1318 | IE_NAME = 'vhx:embed' |
1319 | _VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P<id>\d+)' | |
1320 | ||
29f7c58a | 1321 | @staticmethod |
1322 | def _extract_url(webpage): | |
1323 | mobj = re.search( | |
1324 | r'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage) | |
1325 | return unescapeHTML(mobj.group(1)) if mobj else None | |
1326 | ||
ca01d178 RA |
1327 | def _real_extract(self, url): |
1328 | video_id = self._match_id(url) | |
1329 | webpage = self._download_webpage(url, video_id) | |
a1ee23e9 RA |
1330 | config_url = self._parse_json(self._search_regex( |
1331 | r'window\.OTTData\s*=\s*({.+})', webpage, | |
1332 | 'ott data'), video_id, js_to_json)['config_url'] | |
1333 | config = self._download_json(config_url, video_id) | |
1334 | info = self._parse_config(config, video_id) | |
29f7c58a | 1335 | info['id'] = video_id |
a1ee23e9 RA |
1336 | self._vimeo_sort_formats(info['formats']) |
1337 | return info |