[vimeo:likes] Implement extrator in terms of channel extractor
This allows to obtain videos' ids before extraction (#21493)
This commit is contained in:
parent
9634de178d
commit
091c9b4316
@ -16,7 +16,6 @@ from ..utils import (
|
|||||||
determine_ext,
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
InAdvancePagedList,
|
|
||||||
int_or_none,
|
int_or_none,
|
||||||
merge_dicts,
|
merge_dicts,
|
||||||
NO_DEFAULT,
|
NO_DEFAULT,
|
||||||
@ -1065,7 +1064,7 @@ class VimeoWatchLaterIE(VimeoChannelIE):
|
|||||||
return self._extract_videos('watchlater', 'https://vimeo.com/watchlater')
|
return self._extract_videos('watchlater', 'https://vimeo.com/watchlater')
|
||||||
|
|
||||||
|
|
||||||
class VimeoLikesIE(InfoExtractor):
|
class VimeoLikesIE(VimeoChannelIE):
|
||||||
_VALID_URL = r'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
|
_VALID_URL = r'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
|
||||||
IE_NAME = 'vimeo:likes'
|
IE_NAME = 'vimeo:likes'
|
||||||
IE_DESC = 'Vimeo user likes'
|
IE_DESC = 'Vimeo user likes'
|
||||||
@ -1073,55 +1072,20 @@ class VimeoLikesIE(InfoExtractor):
|
|||||||
'url': 'https://vimeo.com/user755559/likes/',
|
'url': 'https://vimeo.com/user755559/likes/',
|
||||||
'playlist_mincount': 293,
|
'playlist_mincount': 293,
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'user755559_likes',
|
'id': 'user755559',
|
||||||
'description': 'See all the videos urza likes',
|
'title': 'urza’s Likes',
|
||||||
'title': 'Videos urza likes',
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://vimeo.com/stormlapse/likes',
|
'url': 'https://vimeo.com/stormlapse/likes',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
def _page_url(self, base_url, pagenum):
|
||||||
|
return '%s/page:%d/' % (base_url, pagenum)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
user_id = self._match_id(url)
|
user_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, user_id)
|
return self._extract_videos(user_id, 'https://vimeo.com/%s/likes' % user_id)
|
||||||
page_count = self._int(
|
|
||||||
self._search_regex(
|
|
||||||
r'''(?x)<li><a\s+href="[^"]+"\s+data-page="([0-9]+)">
|
|
||||||
.*?</a></li>\s*<li\s+class="pagination_next">
|
|
||||||
''', webpage, 'page count', default=1),
|
|
||||||
'page count', fatal=True)
|
|
||||||
PAGE_SIZE = 12
|
|
||||||
title = self._html_search_regex(
|
|
||||||
r'(?s)<h1>(.+?)</h1>', webpage, 'title', fatal=False)
|
|
||||||
description = self._html_search_meta('description', webpage)
|
|
||||||
|
|
||||||
def _get_page(idx):
|
|
||||||
page_url = 'https://vimeo.com/%s/likes/page:%d/sort:date' % (
|
|
||||||
user_id, idx + 1)
|
|
||||||
webpage = self._download_webpage(
|
|
||||||
page_url, user_id,
|
|
||||||
note='Downloading page %d/%d' % (idx + 1, page_count))
|
|
||||||
video_list = self._search_regex(
|
|
||||||
r'(?s)<ol class="js-browse_list[^"]+"[^>]*>(.*?)</ol>',
|
|
||||||
webpage, 'video content')
|
|
||||||
paths = re.findall(
|
|
||||||
r'<li[^>]*>\s*<a\s+href="([^"]+)"', video_list)
|
|
||||||
for path in paths:
|
|
||||||
yield {
|
|
||||||
'_type': 'url',
|
|
||||||
'url': compat_urlparse.urljoin(page_url, path),
|
|
||||||
}
|
|
||||||
|
|
||||||
pl = InAdvancePagedList(_get_page, page_count, PAGE_SIZE)
|
|
||||||
|
|
||||||
return {
|
|
||||||
'_type': 'playlist',
|
|
||||||
'id': '%s_likes' % user_id,
|
|
||||||
'title': title,
|
|
||||||
'description': description,
|
|
||||||
'entries': pl,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class VHXEmbedIE(InfoExtractor):
|
class VHXEmbedIE(InfoExtractor):
|
||||||
|
Loading…
Reference in New Issue
Block a user