[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 @@ def _real_extract(self, url):
class VKUserVideosIE(VKBaseIE):
IE_NAME = 'vk:uservideos'
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'
_TESTS = [{
'url': 'https://vk.com/video/@mobidevices',
@ -550,6 +550,13 @@ class VKUserVideosIE(VKBaseIE):
'id': '-17892518_uploaded',
},
'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'])
@ -584,11 +591,19 @@ def _entries(self, page_id, section):
def _real_extract(self, url):
u_id, section = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, u_id)
page_id = self._search_regex(r'data-owner-id\s?=\s?"([^"]+)"', webpage, 'page_id')
if u_id.startswith('@'):
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:
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):