From fe5bcc504f9a7956d4d2da303802e79838f403c2 Mon Sep 17 00:00:00 2001 From: Sergey Alirzaev Date: Sun, 1 Sep 2019 23:03:53 +0300 Subject: [PATCH] [yandexmusic] fetch artist's albums --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/yandexmusic.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 4adcae1e5..8e1d12ea3 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1456,6 +1456,7 @@ from .yandexmusic import ( YandexMusicTrackIE, YandexMusicAlbumIE, YandexMusicPlaylistIE, + YandexMusicArtistIE, ) from .yandexvideo import YandexVideoIE from .yapfiles import YapFilesIE diff --git a/youtube_dl/extractor/yandexmusic.py b/youtube_dl/extractor/yandexmusic.py index 08d35e04c..fd350762e 100644 --- a/youtube_dl/extractor/yandexmusic.py +++ b/youtube_dl/extractor/yandexmusic.py @@ -311,3 +311,24 @@ class YandexMusicPlaylistIE(YandexMusicPlaylistBaseIE): self._build_playlist(tracks), compat_str(playlist_id), playlist.get('title'), playlist.get('description')) + + +class YandexMusicArtistIE(YandexMusicPlaylistBaseIE): + IE_NAME = 'yandexmusic:artist' + IE_DESC = 'Яндекс.Музыка - Артист' + _VALID_URL = r'https?://music\.yandex\.(?:ru|kz|ua|by)/artist/(?P\d+)/?(\?|$)' + + def _real_extract(self, url): + artist_id = self._match_id(url) + + artist = self._download_json( + 'http://music.yandex.ru/handlers/artist.jsx?artist=%s' % artist_id, + artist_id, 'Downloading artist JSON') + + entries = [ + self.url_result( + 'http://music.yandex.ru/album/%s' % (album['id']) + ) for album in artist['albums'] + ] + + return self.playlist_result(entries)