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