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