Тайп хинты для 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 typing import TYPE_CHECKING, Optional, Dict
|
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:
|
|
|
|
|
from yandex_music import Client
|
|
|
|
|
|
2019-06-01 17:23:28 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
@model
|
2019-06-01 17:23:28 +09:00
|
|
|
|
class Title(YandexMusicObject):
|
2020-01-30 05:43:09 +09:00
|
|
|
|
"""Класс, представляющий заголовок жанра.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
|
|
Attributes:
|
2020-01-30 05:43:09 +09:00
|
|
|
|
title (:obj:`str`): Заголовок.
|
|
|
|
|
full_title (:obj:`str`, optional): Полный заголовок.
|
Удаление избыточной информации (#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.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
"""
|
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
title: str
|
|
|
|
|
full_title: Optional[str] = None
|
|
|
|
|
client: Optional['Client'] = None
|
2019-06-01 17:23:28 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
def __post_init__(self):
|
2019-11-10 03:11:43 +09:00
|
|
|
|
self._id_attrs = (self.title, self.full_title)
|
2019-06-01 17:23:28 +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['Title']:
|
2020-01-26 22:17:09 +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.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
2020-03-22 06:29:34 +09:00
|
|
|
|
:obj:`yandex_music.Title`: Заголовок жанра.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""
|
2019-06-01 17:23:28 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(Title, cls).de_json(data, client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
|
|
@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_dict(cls, data, client) -> Dict[str, Optional['Title']]:
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
Удаление избыточной информации (#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.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
2020-03-22 06:29:34 +09:00
|
|
|
|
:obj:`list` из :obj:`yandex_music.Title`: Заголовки жанров.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""
|
2019-06-01 17:23:28 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
titles = dict()
|
|
|
|
|
for lang, title in data.items():
|
|
|
|
|
titles.update({lang: cls.de_json(title, client)})
|
|
|
|
|
|
|
|
|
|
return titles
|