From: Sergey M․ Date: Mon, 14 Dec 2020 05:45:56 +0000 (+0700) Subject: [yandexmusic] DRY _VALID_URL base X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=bc87ba842417081f34d112ca94bbb23165dc8633;p=youtube-dl [yandexmusic] DRY _VALID_URL base --- diff --git a/youtube_dl/extractor/yandexmusic.py b/youtube_dl/extractor/yandexmusic.py index 6bd44abbc..1d968454a 100644 --- a/youtube_dl/extractor/yandexmusic.py +++ b/youtube_dl/extractor/yandexmusic.py @@ -15,6 +15,8 @@ from ..utils import ( class YandexMusicBaseIE(InfoExtractor): + _VALID_URL_BASE = r'https?://music\.yandex\.(?Pru|kz|ua|by)' + @staticmethod def _handle_error(response): if isinstance(response, dict): @@ -62,7 +64,7 @@ class YandexMusicBaseIE(InfoExtractor): class YandexMusicTrackIE(YandexMusicBaseIE): IE_NAME = 'yandexmusic:track' IE_DESC = 'Яндекс.Музыка - Трек' - _VALID_URL = r'https?://music\.yandex\.(?Pru|kz|ua|by)/album/(?P\d+)/track/(?P\d+)' + _VALID_URL = r'%s/album/(?P\d+)/track/(?P\d+)' % YandexMusicBaseIE._VALID_URL_BASE _TESTS = [{ 'url': 'http://music.yandex.ru/album/540508/track/4878838', @@ -242,7 +244,7 @@ class YandexMusicPlaylistBaseIE(YandexMusicBaseIE): class YandexMusicAlbumIE(YandexMusicPlaylistBaseIE): IE_NAME = 'yandexmusic:album' IE_DESC = 'Яндекс.Музыка - Альбом' - _VALID_URL = r'https?://music\.yandex\.(?Pru|kz|ua|by)/album/(?P\d+)/?(\?|$)' + _VALID_URL = r'%s/album/(?P\d+)/?(\?|$)' % YandexMusicBaseIE._VALID_URL_BASE _TESTS = [{ 'url': 'http://music.yandex.ru/album/540508', @@ -295,7 +297,7 @@ class YandexMusicAlbumIE(YandexMusicPlaylistBaseIE): class YandexMusicPlaylistIE(YandexMusicPlaylistBaseIE): IE_NAME = 'yandexmusic:playlist' IE_DESC = 'Яндекс.Музыка - Плейлист' - _VALID_URL = r'https?://music\.yandex\.(?Pru|kz|ua|by)/users/(?P[^/]+)/playlists/(?P\d+)' + _VALID_URL = r'%s/users/(?P[^/]+)/playlists/(?P\d+)' % YandexMusicBaseIE._VALID_URL_BASE _TESTS = [{ 'url': 'http://music.yandex.ru/users/music.partners/playlists/1245', @@ -374,7 +376,7 @@ class YandexMusicArtistBaseIE(YandexMusicPlaylistBaseIE): class YandexMusicArtistTracksIE(YandexMusicArtistBaseIE): IE_NAME = 'yandexmusic:artist:tracks' IE_DESC = 'Яндекс.Музыка - Артист - Треки' - _VALID_URL = r'https?://music\.yandex\.(?Pru|kz|ua|by)/artist/(?P\d+)/tracks' + _VALID_URL = r'%s/artist/(?P\d+)/tracks' % YandexMusicBaseIE._VALID_URL_BASE _TESTS = [{ 'url': 'https://music.yandex.ru/artist/617526/tracks', @@ -404,7 +406,7 @@ class YandexMusicArtistTracksIE(YandexMusicArtistBaseIE): class YandexMusicArtistAlbumsIE(YandexMusicArtistBaseIE): IE_NAME = 'yandexmusic:artist:albums' IE_DESC = 'Яндекс.Музыка - Артист - Альбомы' - _VALID_URL = r'https?://music\.yandex\.(?Pru|kz|ua|by)/artist/(?P\d+)/albums' + _VALID_URL = r'%s/artist/(?P\d+)/albums' % YandexMusicBaseIE._VALID_URL_BASE _TESTS = [{ 'url': 'https://music.yandex.ru/artist/617526/albums',