2021-02-02 02:01:55 +09:00
|
|
|
from typing import TYPE_CHECKING, Optional, List, Iterator
|
2019-12-27 18:14:51 +09:00
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
from yandex_music import YandexMusicObject
|
2021-09-19 22:47:19 +09:00
|
|
|
from yandex_music.utils import model
|
2020-01-26 21:19:22 +09:00
|
|
|
|
2019-12-27 18:14:51 +09:00
|
|
|
if TYPE_CHECKING:
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
from yandex_music import Client, Album, Pager
|
2019-12-27 18:14:51 +09:00
|
|
|
|
2019-11-20 02:30:07 +09:00
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
@model
|
2019-11-20 02:30:07 +09:00
|
|
|
class ArtistAlbums(YandexMusicObject):
|
2020-01-26 08:55:56 +09:00
|
|
|
"""Класс, представляющий страницу списка альбомов артиста.
|
2019-11-20 02:52:17 +09:00
|
|
|
|
|
|
|
Attributes:
|
|
|
|
albums (:obj:`list` из :obj:`yandex_music.Album`): Список альбомов артиста.
|
2020-03-22 06:29:34 +09:00
|
|
|
pager (:obj:`yandex_music.Pager`): Пагинатор.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-11-20 02:52:17 +09:00
|
|
|
"""
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
albums: List['Album']
|
|
|
|
pager: Optional['Pager']
|
|
|
|
client: Optional['Client'] = None
|
2019-11-20 02:30:07 +09:00
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
def __post_init__(self):
|
2019-11-20 02:30:07 +09:00
|
|
|
self._id_attrs = (self.pager, self.albums)
|
|
|
|
|
2021-02-02 02:01:55 +09:00
|
|
|
def __getitem__(self, item) -> 'Album':
|
|
|
|
return self.albums[item]
|
|
|
|
|
|
|
|
def __iter__(self) -> Iterator['Album']:
|
|
|
|
return iter(self.albums)
|
|
|
|
|
|
|
|
def __len__(self) -> int:
|
|
|
|
return len(self.albums)
|
|
|
|
|
2019-11-20 02:30:07 +09:00
|
|
|
@classmethod
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistAlbums']:
|
2019-11-20 02:52:17 +09:00
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
data (:obj:`dict`): Поля и значения десериализуемого объекта.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-11-20 02:52:17 +09:00
|
|
|
|
|
|
|
Returns:
|
2020-03-22 06:29:34 +09:00
|
|
|
:obj:`yandex_music.ArtistAlbums`: Список альбомов артиста.
|
2019-11-20 02:52:17 +09:00
|
|
|
"""
|
2019-11-20 02:30:07 +09:00
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
|
|
|
data = super(ArtistAlbums, cls).de_json(data, client)
|
|
|
|
from yandex_music import Album, Pager
|
2021-02-03 21:28:10 +09:00
|
|
|
|
2019-11-20 02:30:07 +09:00
|
|
|
data['albums'] = Album.de_list(data.get('albums'), client)
|
|
|
|
data['pager'] = Pager.de_json(data.get('pager'), client)
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|