[VK] Fix playlist URLs (#4930)

Closes #2825
Authored by: the-marenga
This commit is contained in:
Marenga 2022-10-09 03:50:44 +02:00 committed by GitHub
parent 540236ce11
commit 5d14b73491
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -536,7 +536,7 @@ class VKIE(VKBaseIE):
class VKUserVideosIE(VKBaseIE): class VKUserVideosIE(VKBaseIE):
IE_NAME = 'vk:uservideos' IE_NAME = 'vk:uservideos'
IE_DESC = "VK - User's Videos" IE_DESC = "VK - User's Videos"
_VALID_URL = r'https?://(?:(?:m|new)\.)?vk\.com/video/@(?P<id>[^?$#/&]+)(?!\?.*\bz=video)(?:[/?#&](?:.*?\bsection=(?P<section>\w+))?|$)' _VALID_URL = r'https?://(?:(?:m|new)\.)?vk\.com/video/(?:playlist/)?(?P<id>[^?$#/&]+)(?!\?.*\bz=video)(?:[/?#&](?:.*?\bsection=(?P<section>\w+))?|$)'
_TEMPLATE_URL = 'https://vk.com/videos' _TEMPLATE_URL = 'https://vk.com/videos'
_TESTS = [{ _TESTS = [{
'url': 'https://vk.com/video/@mobidevices', 'url': 'https://vk.com/video/@mobidevices',
@ -550,6 +550,13 @@ class VKUserVideosIE(VKBaseIE):
'id': '-17892518_uploaded', 'id': '-17892518_uploaded',
}, },
'playlist_mincount': 182, 'playlist_mincount': 182,
}, {
'url': 'https://vk.com/video/playlist/-174476437_2',
'info_dict': {
'id': '-174476437_2',
'title': 'Анонсы'
},
'playlist_mincount': 108,
}] }]
_VIDEO = collections.namedtuple('Video', ['owner_id', 'id']) _VIDEO = collections.namedtuple('Video', ['owner_id', 'id'])
@ -584,11 +591,19 @@ class VKUserVideosIE(VKBaseIE):
def _real_extract(self, url): def _real_extract(self, url):
u_id, section = self._match_valid_url(url).groups() u_id, section = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, u_id) webpage = self._download_webpage(url, u_id)
if u_id.startswith('@'):
page_id = self._search_regex(r'data-owner-id\s?=\s?"([^"]+)"', webpage, 'page_id') page_id = self._search_regex(r'data-owner-id\s?=\s?"([^"]+)"', webpage, 'page_id')
elif '_' in u_id:
page_id, section = u_id.split('_', 1)
else:
raise ExtractorError('Invalid URL', expected=True)
if not section: if not section:
section = 'all' section = 'all'
return self.playlist_result(self._entries(page_id, section), '%s_%s' % (page_id, section)) playlist_title = clean_html(get_element_by_class('VideoInfoPanel__title', webpage))
return self.playlist_result(self._entries(page_id, section), '%s_%s' % (page_id, section), playlist_title)
class VKWallPostIE(VKBaseIE): class VKWallPostIE(VKBaseIE):