]>
Commit | Line | Data |
---|---|---|
93b22c78 | 1 | # encoding: utf-8 |
9148eb00 PH |
2 | from __future__ import unicode_literals |
3 | ||
b3d14cbf PH |
4 | import json |
5 | import re | |
caeefc29 | 6 | import itertools |
b3d14cbf PH |
7 | |
8 | from .common import InfoExtractor | |
1eac553e | 9 | from .subtitles import SubtitlesInfoExtractor |
b3d14cbf | 10 | from ..utils import ( |
1060425c | 11 | compat_HTTPError, |
b3d14cbf PH |
12 | compat_urllib_parse, |
13 | compat_urllib_request, | |
b3d14cbf PH |
14 | clean_html, |
15 | get_element_by_attribute, | |
16 | ExtractorError, | |
55b3e45b | 17 | RegexNotFoundError, |
b3d14cbf | 18 | std_headers, |
9d4660ca | 19 | unsmuggle_url, |
a980bc43 | 20 | urlencode_postdata, |
69c8fb9e | 21 | int_or_none, |
b3d14cbf PH |
22 | ) |
23 | ||
bbafbe20 | 24 | |
efb7e119 JMF |
25 | class VimeoBaseInfoExtractor(InfoExtractor): |
26 | _NETRC_MACHINE = 'vimeo' | |
27 | _LOGIN_REQUIRED = False | |
28 | ||
29 | def _login(self): | |
30 | (username, password) = self._get_login_info() | |
31 | if username is None: | |
32 | if self._LOGIN_REQUIRED: | |
4f3e9430 | 33 | raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True) |
efb7e119 JMF |
34 | return |
35 | self.report_login() | |
36 | login_url = 'https://vimeo.com/log_in' | |
37 | webpage = self._download_webpage(login_url, None, False) | |
38 | token = self._search_regex(r'xsrft: \'(.*?)\'', webpage, 'login token') | |
39 | data = urlencode_postdata({ | |
40 | 'email': username, | |
41 | 'password': password, | |
42 | 'action': 'login', | |
43 | 'service': 'vimeo', | |
44 | 'token': token, | |
45 | }) | |
46 | login_request = compat_urllib_request.Request(login_url, data) | |
47 | login_request.add_header('Content-Type', 'application/x-www-form-urlencoded') | |
48 | login_request.add_header('Cookie', 'xsrft=%s' % token) | |
49 | self._download_webpage(login_request, None, False, 'Wrong login info') | |
50 | ||
51 | ||
52 | class VimeoIE(VimeoBaseInfoExtractor, SubtitlesInfoExtractor): | |
b3d14cbf PH |
53 | """Information extractor for vimeo.com.""" |
54 | ||
55 | # _VALID_URL matches Vimeo URLs | |
bbafbe20 | 56 | _VALID_URL = r'''(?x) |
3fabeaa1 | 57 | (?P<proto>(?:https?:)?//)? |
bbafbe20 PH |
58 | (?:(?:www|(?P<player>player))\.)? |
59 | vimeo(?P<pro>pro)?\.com/ | |
2929b3e7 | 60 | (?!channels/[^/?#]+/?(?:$|[?#])|album/) |
bbafbe20 | 61 | (?:.*?/)? |
7115ca84 | 62 | (?:(?:play_redirect_hls|moogaloop\.swf)\?clip_id=)? |
bbafbe20 PH |
63 | (?:videos?/)? |
64 | (?P<id>[0-9]+) | |
7115ca84 | 65 | /?(?:[?&].*)?(?:[#].*)?$''' |
9148eb00 | 66 | IE_NAME = 'vimeo' |
a91b954b JMF |
67 | _TESTS = [ |
68 | { | |
9148eb00 | 69 | 'url': 'http://vimeo.com/56015672#at=0', |
9148eb00 PH |
70 | 'md5': '8879b6cc097e987f02484baf890129e5', |
71 | 'info_dict': { | |
ad5976b4 PH |
72 | 'id': '56015672', |
73 | 'ext': 'mp4', | |
74 | "upload_date": "20121220", | |
75 | "description": "This is a test case for youtube-dl.\nFor more information, see github.com/rg3/youtube-dl\nTest chars: \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550", | |
76 | "uploader_id": "user7108434", | |
77 | "uploader": "Filippo Valsorda", | |
9148eb00 | 78 | "title": "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550", |
69c8fb9e | 79 | "duration": 10, |
a91b954b JMF |
80 | }, |
81 | }, | |
82 | { | |
9148eb00 | 83 | 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876', |
9148eb00 PH |
84 | 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82', |
85 | 'note': 'Vimeo Pro video (#1197)', | |
86 | 'info_dict': { | |
4f3e9430 JMF |
87 | 'id': '68093876', |
88 | 'ext': 'mp4', | |
9148eb00 PH |
89 | 'uploader_id': 'openstreetmapus', |
90 | 'uploader': 'OpenStreetMap US', | |
91 | 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography', | |
69c8fb9e | 92 | 'duration': 1595, |
a91b954b JMF |
93 | }, |
94 | }, | |
aa32314d | 95 | { |
9148eb00 | 96 | 'url': 'http://player.vimeo.com/video/54469442', |
9148eb00 PH |
97 | 'md5': '619b811a4417aa4abe78dc653becf511', |
98 | 'note': 'Videos that embed the url in the player page', | |
99 | 'info_dict': { | |
4f3e9430 JMF |
100 | 'id': '54469442', |
101 | 'ext': 'mp4', | |
0e6ebc13 | 102 | 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012', |
9148eb00 PH |
103 | 'uploader': 'The BLN & Business of Software', |
104 | 'uploader_id': 'theblnbusinessofsoftware', | |
69c8fb9e | 105 | 'duration': 3610, |
aa32314d | 106 | }, |
93b22c78 JMF |
107 | }, |
108 | { | |
9148eb00 | 109 | 'url': 'http://vimeo.com/68375962', |
9148eb00 PH |
110 | 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7', |
111 | 'note': 'Video protected with password', | |
112 | 'info_dict': { | |
4f3e9430 JMF |
113 | 'id': '68375962', |
114 | 'ext': 'mp4', | |
9148eb00 PH |
115 | 'title': 'youtube-dl password protected test video', |
116 | 'upload_date': '20130614', | |
117 | 'uploader_id': 'user18948128', | |
118 | 'uploader': 'Jaime Marquínez Ferrándiz', | |
69c8fb9e | 119 | 'duration': 10, |
93b22c78 | 120 | }, |
9148eb00 PH |
121 | 'params': { |
122 | 'videopassword': 'youtube-dl', | |
93b22c78 JMF |
123 | }, |
124 | }, | |
548f31d9 S |
125 | { |
126 | 'url': 'http://vimeo.com/channels/keypeele/75629013', | |
127 | 'md5': '2f86a05afe9d7abc0b9126d229bbe15d', | |
128 | 'note': 'Video is freely available via original URL ' | |
129 | 'and protected with password when accessed via http://vimeo.com/75629013', | |
130 | 'info_dict': { | |
131 | 'id': '75629013', | |
132 | 'ext': 'mp4', | |
133 | 'title': 'Key & Peele: Terrorist Interrogation', | |
134 | 'description': 'md5:8678b246399b070816b12313e8b4eb5c', | |
135 | 'uploader_id': 'atencio', | |
136 | 'uploader': 'Peter Atencio', | |
137 | 'duration': 187, | |
138 | }, | |
139 | }, | |
1eac553e S |
140 | { |
141 | 'url': 'http://vimeo.com/76979871', | |
142 | 'md5': '3363dd6ffebe3784d56f4132317fd446', | |
143 | 'note': 'Video with subtitles', | |
144 | 'info_dict': { | |
145 | 'id': '76979871', | |
146 | 'ext': 'mp4', | |
147 | 'title': 'The New Vimeo Player (You Know, For Videos)', | |
148 | 'description': 'md5:2ec900bf97c3f389378a96aee11260ea', | |
149 | 'upload_date': '20131015', | |
150 | 'uploader_id': 'staff', | |
151 | 'uploader': 'Vimeo Staff', | |
69c8fb9e | 152 | 'duration': 62, |
1eac553e S |
153 | } |
154 | }, | |
a91b954b | 155 | ] |
b3d14cbf PH |
156 | |
157 | def _verify_video_password(self, url, video_id, webpage): | |
c6c19746 | 158 | password = self._downloader.params.get('videopassword', None) |
b3d14cbf | 159 | if password is None: |
9148eb00 | 160 | raise ExtractorError('This video is protected by a password, use the --video-password option') |
fcee8ee7 | 161 | token = self._search_regex(r'xsrft: \'(.*?)\'', webpage, 'login token') |
4f3e9430 JMF |
162 | data = compat_urllib_parse.urlencode({ |
163 | 'password': password, | |
164 | 'token': token, | |
165 | }) | |
b3d14cbf PH |
166 | # I didn't manage to use the password with https |
167 | if url.startswith('https'): | |
4f3e9430 | 168 | pass_url = url.replace('https', 'http') |
b3d14cbf PH |
169 | else: |
170 | pass_url = url | |
4f3e9430 | 171 | password_request = compat_urllib_request.Request(pass_url + '/password', data) |
b3d14cbf PH |
172 | password_request.add_header('Content-Type', 'application/x-www-form-urlencoded') |
173 | password_request.add_header('Cookie', 'xsrft=%s' % token) | |
174 | self._download_webpage(password_request, video_id, | |
9148eb00 PH |
175 | 'Verifying the password', |
176 | 'Wrong password') | |
b3d14cbf | 177 | |
0eecc6a4 PH |
178 | def _verify_player_video_password(self, url, video_id): |
179 | password = self._downloader.params.get('videopassword', None) | |
180 | if password is None: | |
181 | raise ExtractorError('This video is protected by a password, use the --video-password option') | |
182 | data = compat_urllib_parse.urlencode({'password': password}) | |
183 | pass_url = url + '/check-password' | |
184 | password_request = compat_urllib_request.Request(pass_url, data) | |
185 | password_request.add_header('Content-Type', 'application/x-www-form-urlencoded') | |
186 | return self._download_json( | |
187 | password_request, video_id, | |
188 | 'Verifying the password', | |
189 | 'Wrong password') | |
190 | ||
fc79158d JMF |
191 | def _real_initialize(self): |
192 | self._login() | |
193 | ||
a0088bdf | 194 | def _real_extract(self, url): |
9d4660ca PH |
195 | url, data = unsmuggle_url(url) |
196 | headers = std_headers | |
197 | if data is not None: | |
198 | headers = headers.copy() | |
199 | headers.update(data) | |
ba5d51b3 PH |
200 | if 'Referer' not in headers: |
201 | headers['Referer'] = url | |
9d4660ca | 202 | |
b3d14cbf PH |
203 | # Extract ID from URL |
204 | mobj = re.match(self._VALID_URL, url) | |
b3d14cbf | 205 | video_id = mobj.group('id') |
9103bbc5 | 206 | if mobj.group('pro') or mobj.group('player'): |
a91b954b | 207 | url = 'http://player.vimeo.com/video/' + video_id |
b3d14cbf PH |
208 | |
209 | # Retrieve video webpage to extract further information | |
9d4660ca | 210 | request = compat_urllib_request.Request(url, None, headers) |
1060425c PH |
211 | try: |
212 | webpage = self._download_webpage(request, video_id) | |
213 | except ExtractorError as ee: | |
214 | if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403: | |
215 | errmsg = ee.cause.read() | |
216 | if b'Because of its privacy settings, this video cannot be played here' in errmsg: | |
217 | raise ExtractorError( | |
218 | 'Cannot download embed-only video without embedding ' | |
219 | 'URL. Please call youtube-dl with the URL of the page ' | |
220 | 'that embeds this video.', | |
221 | expected=True) | |
222 | raise | |
b3d14cbf PH |
223 | |
224 | # Now we begin extracting as much information as we can from what we | |
225 | # retrieved. First we extract the information common to all extractors, | |
226 | # and latter we extract those that are Vimeo specific. | |
227 | self.report_extraction(video_id) | |
228 | ||
229 | # Extract the config JSON | |
230 | try: | |
93b22c78 JMF |
231 | try: |
232 | config_url = self._html_search_regex( | |
9148eb00 | 233 | r' data-config-url="(.+?)"', webpage, 'config URL') |
93b22c78 JMF |
234 | config_json = self._download_webpage(config_url, video_id) |
235 | config = json.loads(config_json) | |
236 | except RegexNotFoundError: | |
237 | # For pro videos or player.vimeo.com urls | |
48ad51b2 JMF |
238 | # We try to find out to which variable is assigned the config dic |
239 | m_variable_name = re.search('(\w)\.video\.id', webpage) | |
240 | if m_variable_name is not None: | |
241 | config_re = r'%s=({.+?});' % re.escape(m_variable_name.group(1)) | |
242 | else: | |
243 | config_re = [r' = {config:({.+?}),assets:', r'(?:[abc])=({.+?});'] | |
9148eb00 | 244 | config = self._search_regex(config_re, webpage, 'info section', |
48ad51b2 | 245 | flags=re.DOTALL) |
93b22c78 | 246 | config = json.loads(config) |
71907db3 | 247 | except Exception as e: |
b3d14cbf | 248 | if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage): |
9148eb00 | 249 | raise ExtractorError('The author has restricted the access to this video, try with the "--referer" option') |
b3d14cbf | 250 | |
93b22c78 | 251 | if re.search('<form[^>]+?id="pw_form"', webpage) is not None: |
b3d14cbf PH |
252 | self._verify_video_password(url, video_id, webpage) |
253 | return self._real_extract(url) | |
254 | else: | |
9148eb00 | 255 | raise ExtractorError('Unable to extract info section', |
71907db3 | 256 | cause=e) |
559e370f PH |
257 | else: |
258 | if config.get('view') == 4: | |
0eecc6a4 | 259 | config = self._verify_player_video_password(url, video_id) |
b3d14cbf PH |
260 | |
261 | # Extract title | |
262 | video_title = config["video"]["title"] | |
263 | ||
264 | # Extract uploader and uploader_id | |
265 | video_uploader = config["video"]["owner"]["name"] | |
266 | video_uploader_id = config["video"]["owner"]["url"].split('/')[-1] if config["video"]["owner"]["url"] else None | |
267 | ||
268 | # Extract video thumbnail | |
aa32314d | 269 | video_thumbnail = config["video"].get("thumbnail") |
c0e5d856 S |
270 | if video_thumbnail is None: |
271 | video_thumbs = config["video"].get("thumbs") | |
272 | if video_thumbs and isinstance(video_thumbs, dict): | |
3e510af3 | 273 | _, video_thumbnail = sorted((int(width if width.isdigit() else 0), t_url) for (width, t_url) in video_thumbs.items())[-1] |
b3d14cbf PH |
274 | |
275 | # Extract video description | |
9c2ade40 JMF |
276 | video_description = None |
277 | try: | |
7558830f JMF |
278 | video_description = get_element_by_attribute("class", "description_wrapper", webpage) |
279 | if video_description: | |
280 | video_description = clean_html(video_description) | |
9c2ade40 JMF |
281 | except AssertionError as err: |
282 | # On some pages like (http://player.vimeo.com/video/54469442) the | |
283 | # html tags are not closed, python 2.6 cannot handle it | |
284 | if err.args[0] == 'we should not get here!': | |
285 | pass | |
286 | else: | |
287 | raise | |
b3d14cbf | 288 | |
69c8fb9e S |
289 | # Extract video duration |
290 | video_duration = int_or_none(config["video"].get("duration")) | |
291 | ||
b3d14cbf PH |
292 | # Extract upload date |
293 | video_upload_date = None | |
294 | mobj = re.search(r'<meta itemprop="dateCreated" content="(\d{4})-(\d{2})-(\d{2})T', webpage) | |
295 | if mobj is not None: | |
296 | video_upload_date = mobj.group(1) + mobj.group(2) + mobj.group(3) | |
297 | ||
4e761794 | 298 | try: |
9148eb00 PH |
299 | view_count = int(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count')) |
300 | like_count = int(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count')) | |
301 | comment_count = int(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count')) | |
4e761794 JMF |
302 | except RegexNotFoundError: |
303 | # This info is only available in vimeo.com/{id} urls | |
304 | view_count = None | |
305 | like_count = None | |
306 | comment_count = None | |
307 | ||
b3d14cbf PH |
308 | # Vimeo specific: extract request signature and timestamp |
309 | sig = config['request']['signature'] | |
310 | timestamp = config['request']['timestamp'] | |
311 | ||
312 | # Vimeo specific: extract video codec and quality information | |
313 | # First consider quality, then codecs, then take everything | |
a6387bfd | 314 | codecs = [('vp6', 'flv'), ('vp8', 'flv'), ('h264', 'mp4')] |
a56f9de1 | 315 | files = {'hd': [], 'sd': [], 'other': []} |
aa32314d | 316 | config_files = config["video"].get("files") or config["request"].get("files") |
b3d14cbf | 317 | for codec_name, codec_extension in codecs: |
a6387bfd JE |
318 | for quality in config_files.get(codec_name, []): |
319 | format_id = '-'.join((codec_name, quality)).lower() | |
320 | key = quality if quality in files else 'other' | |
321 | video_url = None | |
322 | if isinstance(config_files[codec_name], dict): | |
323 | file_info = config_files[codec_name][quality] | |
324 | video_url = file_info.get('url') | |
b3d14cbf | 325 | else: |
a6387bfd JE |
326 | file_info = {} |
327 | if video_url is None: | |
328 | video_url = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=%s&type=moogaloop_local&embed_location=" \ | |
4f3e9430 | 329 | % (video_id, sig, timestamp, quality, codec_name.upper()) |
a6387bfd JE |
330 | |
331 | files[key].append({ | |
332 | 'ext': codec_extension, | |
333 | 'url': video_url, | |
334 | 'format_id': format_id, | |
335 | 'width': file_info.get('width'), | |
336 | 'height': file_info.get('height'), | |
337 | }) | |
338 | formats = [] | |
339 | for key in ('other', 'sd', 'hd'): | |
340 | formats += files[key] | |
341 | if len(formats) == 0: | |
9148eb00 | 342 | raise ExtractorError('No known codec found') |
b3d14cbf | 343 | |
1eac553e S |
344 | subtitles = {} |
345 | text_tracks = config['request'].get('text_tracks') | |
346 | if text_tracks: | |
347 | for tt in text_tracks: | |
348 | subtitles[tt['lang']] = 'http://vimeo.com' + tt['url'] | |
349 | ||
350 | video_subtitles = self.extract_subtitles(video_id, subtitles) | |
351 | if self._downloader.params.get('listsubtitles', False): | |
352 | self._list_available_subtitles(video_id, subtitles) | |
353 | return | |
354 | ||
9103bbc5 | 355 | return { |
b0268cb6 | 356 | 'id': video_id, |
b3d14cbf PH |
357 | 'uploader': video_uploader, |
358 | 'uploader_id': video_uploader_id, | |
b0268cb6 S |
359 | 'upload_date': video_upload_date, |
360 | 'title': video_title, | |
361 | 'thumbnail': video_thumbnail, | |
362 | 'description': video_description, | |
69c8fb9e | 363 | 'duration': video_duration, |
a6387bfd | 364 | 'formats': formats, |
9103bbc5 | 365 | 'webpage_url': url, |
4e761794 JMF |
366 | 'view_count': view_count, |
367 | 'like_count': like_count, | |
368 | 'comment_count': comment_count, | |
1eac553e | 369 | 'subtitles': video_subtitles, |
9103bbc5 | 370 | } |
caeefc29 JMF |
371 | |
372 | ||
373 | class VimeoChannelIE(InfoExtractor): | |
9148eb00 | 374 | IE_NAME = 'vimeo:channel' |
2929b3e7 | 375 | _VALID_URL = r'https?://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])' |
caeefc29 | 376 | _MORE_PAGES_INDICATOR = r'<a.+?rel="next"' |
55a10eab | 377 | _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"' |
2929b3e7 PH |
378 | _TESTS = [{ |
379 | 'url': 'http://vimeo.com/channels/tributes', | |
380 | 'info_dict': { | |
381 | 'title': 'Vimeo Tributes', | |
382 | }, | |
383 | 'playlist_mincount': 25, | |
384 | }] | |
caeefc29 | 385 | |
5cc14c2f JMF |
386 | def _page_url(self, base_url, pagenum): |
387 | return '%s/videos/page:%d/' % (base_url, pagenum) | |
388 | ||
fb30ec22 | 389 | def _extract_list_title(self, webpage): |
9148eb00 | 390 | return self._html_search_regex(self._TITLE_RE, webpage, 'list title') |
fb30ec22 | 391 | |
55a10eab | 392 | def _extract_videos(self, list_id, base_url): |
caeefc29 | 393 | video_ids = [] |
caeefc29 | 394 | for pagenum in itertools.count(1): |
55a10eab | 395 | webpage = self._download_webpage( |
4f3e9430 | 396 | self._page_url(base_url, pagenum), list_id, |
9148eb00 | 397 | 'Downloading page %s' % pagenum) |
caeefc29 JMF |
398 | video_ids.extend(re.findall(r'id="clip_(\d+?)"', webpage)) |
399 | if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None: | |
400 | break | |
401 | ||
402 | entries = [self.url_result('http://vimeo.com/%s' % video_id, 'Vimeo') | |
403 | for video_id in video_ids] | |
caeefc29 | 404 | return {'_type': 'playlist', |
55a10eab | 405 | 'id': list_id, |
fb30ec22 | 406 | 'title': self._extract_list_title(webpage), |
caeefc29 JMF |
407 | 'entries': entries, |
408 | } | |
55a10eab JMF |
409 | |
410 | def _real_extract(self, url): | |
411 | mobj = re.match(self._VALID_URL, url) | |
4f3e9430 | 412 | channel_id = mobj.group('id') |
55a10eab JMF |
413 | return self._extract_videos(channel_id, 'http://vimeo.com/channels/%s' % channel_id) |
414 | ||
415 | ||
416 | class VimeoUserIE(VimeoChannelIE): | |
9148eb00 | 417 | IE_NAME = 'vimeo:user' |
2929b3e7 | 418 | _VALID_URL = r'https?://vimeo\.com/(?![0-9]+(?:$|[?#/]))(?P<name>[^/]+)(?:/videos|[#?]|$)' |
55a10eab | 419 | _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>' |
2929b3e7 PH |
420 | _TESTS = [{ |
421 | 'url': 'http://vimeo.com/nkistudio/videos', | |
422 | 'info_dict': { | |
423 | 'title': 'Nki', | |
424 | }, | |
425 | 'playlist_mincount': 66, | |
426 | }] | |
55a10eab JMF |
427 | |
428 | def _real_extract(self, url): | |
429 | mobj = re.match(self._VALID_URL, url) | |
430 | name = mobj.group('name') | |
431 | return self._extract_videos(name, 'http://vimeo.com/%s' % name) | |
5cc14c2f JMF |
432 | |
433 | ||
434 | class VimeoAlbumIE(VimeoChannelIE): | |
9148eb00 | 435 | IE_NAME = 'vimeo:album' |
2929b3e7 | 436 | _VALID_URL = r'https?://vimeo\.com/album/(?P<id>\d+)' |
5cc14c2f | 437 | _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>' |
2929b3e7 PH |
438 | _TESTS = [{ |
439 | 'url': 'http://vimeo.com/album/2632481', | |
440 | 'info_dict': { | |
441 | 'title': 'Staff Favorites: November 2013', | |
442 | }, | |
443 | 'playlist_mincount': 13, | |
444 | }] | |
5cc14c2f JMF |
445 | |
446 | def _page_url(self, base_url, pagenum): | |
447 | return '%s/page:%d/' % (base_url, pagenum) | |
448 | ||
449 | def _real_extract(self, url): | |
450 | mobj = re.match(self._VALID_URL, url) | |
fcea44c6 | 451 | album_id = mobj.group('id') |
5cc14c2f | 452 | return self._extract_videos(album_id, 'http://vimeo.com/album/%s' % album_id) |
fb30ec22 JMF |
453 | |
454 | ||
455 | class VimeoGroupsIE(VimeoAlbumIE): | |
9148eb00 | 456 | IE_NAME = 'vimeo:group' |
59188de1 | 457 | _VALID_URL = r'(?:https?://)?vimeo\.com/groups/(?P<name>[^/]+)' |
2929b3e7 PH |
458 | _TESTS = [{ |
459 | 'url': 'http://vimeo.com/groups/rolexawards', | |
460 | 'info_dict': { | |
461 | 'title': 'Rolex Awards for Enterprise', | |
462 | }, | |
463 | 'playlist_mincount': 73, | |
464 | }] | |
fb30ec22 JMF |
465 | |
466 | def _extract_list_title(self, webpage): | |
467 | return self._og_search_title(webpage) | |
468 | ||
469 | def _real_extract(self, url): | |
470 | mobj = re.match(self._VALID_URL, url) | |
471 | name = mobj.group('name') | |
472 | return self._extract_videos(name, 'http://vimeo.com/groups/%s' % name) | |
fcea44c6 PH |
473 | |
474 | ||
475 | class VimeoReviewIE(InfoExtractor): | |
9148eb00 PH |
476 | IE_NAME = 'vimeo:review' |
477 | IE_DESC = 'Review pages on vimeo' | |
d36d3f42 PH |
478 | _VALID_URL = r'https?://vimeo\.com/[^/]+/review/(?P<id>[^/]+)' |
479 | _TESTS = [{ | |
fcea44c6 PH |
480 | 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d', |
481 | 'file': '75524534.mp4', | |
482 | 'md5': 'c507a72f780cacc12b2248bb4006d253', | |
483 | 'info_dict': { | |
484 | 'title': "DICK HARDWICK 'Comedian'", | |
485 | 'uploader': 'Richard Hardwick', | |
486 | } | |
d36d3f42 PH |
487 | }, { |
488 | 'note': 'video player needs Referer', | |
489 | 'url': 'http://vimeo.com/user22258446/review/91613211/13f927e053', | |
490 | 'md5': '6295fdab8f4bf6a002d058b2c6dce276', | |
491 | 'info_dict': { | |
492 | 'id': '91613211', | |
493 | 'ext': 'mp4', | |
494 | 'title': 'Death by dogma versus assembling agile - Sander Hoogendoorn', | |
495 | 'uploader': 'DevWeek Events', | |
496 | 'duration': 2773, | |
497 | 'thumbnail': 're:^https?://.*\.jpg$', | |
498 | } | |
499 | }] | |
fcea44c6 PH |
500 | |
501 | def _real_extract(self, url): | |
502 | mobj = re.match(self._VALID_URL, url) | |
503 | video_id = mobj.group('id') | |
504 | player_url = 'https://player.vimeo.com/player/' + video_id | |
505 | return self.url_result(player_url, 'Vimeo', video_id) | |
efb7e119 JMF |
506 | |
507 | ||
508 | class VimeoWatchLaterIE(VimeoBaseInfoExtractor, VimeoChannelIE): | |
509 | IE_NAME = 'vimeo:watchlater' | |
510 | IE_DESC = 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)' | |
511 | _VALID_URL = r'https?://vimeo\.com/home/watchlater|:vimeowatchlater' | |
512 | _LOGIN_REQUIRED = True | |
513 | _TITLE_RE = r'href="/home/watchlater".*?>(.*?)<' | |
2929b3e7 PH |
514 | _TESTS = [{ |
515 | 'url': 'http://vimeo.com/home/watchlater', | |
516 | 'only_matching': True, | |
517 | }] | |
efb7e119 JMF |
518 | |
519 | def _real_initialize(self): | |
520 | self._login() | |
521 | ||
522 | def _page_url(self, base_url, pagenum): | |
523 | url = '%s/page:%d/' % (base_url, pagenum) | |
524 | request = compat_urllib_request.Request(url) | |
525 | # Set the header to get a partial html page with the ids, | |
526 | # the normal page doesn't contain them. | |
527 | request.add_header('X-Requested-With', 'XMLHttpRequest') | |
528 | return request | |
529 | ||
530 | def _real_extract(self, url): | |
531 | return self._extract_videos('watchlater', 'https://vimeo.com/home/watchlater') |