aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/vimeo.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-12-01 22:36:18 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-12-01 22:36:18 +0100
commit55a10eab48776197245d3d87b86195f182d8d82a (patch)
treec96c845cfc43cf6e6639ef0a3131739b30bf3846 /youtube_dl/extractor/vimeo.py
parent355e4fd07e7f9c0632d9d78415675f8b5cc3c2ce (diff)
downloadyoutube-dl-55a10eab48776197245d3d87b86195f182d8d82a.tar.xz
[vimeo] Add an extractor for users (closes #1871)
Diffstat (limited to 'youtube_dl/extractor/vimeo.py')
-rw-r--r--youtube_dl/extractor/vimeo.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/youtube_dl/extractor/vimeo.py b/youtube_dl/extractor/vimeo.py
index 7d82c2cfa..f27763ae2 100644
--- a/youtube_dl/extractor/vimeo.py
+++ b/youtube_dl/extractor/vimeo.py
@@ -249,25 +249,46 @@ class VimeoChannelIE(InfoExtractor):
IE_NAME = u'vimeo:channel'
_VALID_URL = r'(?:https?://)?vimeo.\com/channels/(?P<id>[^/]+)'
_MORE_PAGES_INDICATOR = r'<a.+?rel="next"'
+ _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"'
- def _real_extract(self, url):
- mobj = re.match(self._VALID_URL, url)
- channel_id = mobj.group('id')
+ def _extract_videos(self, list_id, base_url):
video_ids = []
-
for pagenum in itertools.count(1):
- webpage = self._download_webpage('http://vimeo.com/channels/%s/videos/page:%d' % (channel_id, pagenum),
- channel_id, u'Downloading page %s' % pagenum)
+ webpage = self._download_webpage(
+ '%s/videos/page:%d/' % (base_url, pagenum),list_id,
+ u'Downloading page %s' % pagenum)
video_ids.extend(re.findall(r'id="clip_(\d+?)"', webpage))
if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
break
entries = [self.url_result('http://vimeo.com/%s' % video_id, 'Vimeo')
for video_id in video_ids]
- channel_title = self._html_search_regex(r'<a href="/channels/%s">(.*?)</a>' % channel_id,
- webpage, u'channel title')
+ list_title = self._html_search_regex(self._TITLE_RE, webpage,
+ u'list title')
return {'_type': 'playlist',
- 'id': channel_id,
- 'title': channel_title,
+ 'id': list_id,
+ 'title': list_title,
'entries': entries,
}
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ channel_id = mobj.group('id')
+ return self._extract_videos(channel_id, 'http://vimeo.com/channels/%s' % channel_id)
+
+
+class VimeoUserIE(VimeoChannelIE):
+ IE_NAME = u'vimeo:user'
+ _VALID_URL = r'(?:https?://)?vimeo.\com/(?P<name>[^/]+)'
+ _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>'
+
+ @classmethod
+ def suitable(cls, url):
+ if VimeoChannelIE.suitable(url) or VimeoIE.suitable(url):
+ return False
+ return super(VimeoUserIE, cls).suitable(url)
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ name = mobj.group('name')
+ return self._extract_videos(name, 'http://vimeo.com/%s' % name)