2020-05-15 04:44:57 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional
|
|
|
|
|
|
|
|
|
|
from yandex_music import YandexMusicObject
|
2021-09-19 22:47:19 +09:00
|
|
|
|
from yandex_music.utils import model
|
2020-05-15 04:44:57 +09:00
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from yandex_music import Client
|
|
|
|
|
|
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
@model
|
2020-05-15 04:44:57 +09:00
|
|
|
|
class Tag(YandexMusicObject):
|
|
|
|
|
"""Класс, представляющий тег (подборку).
|
|
|
|
|
|
|
|
|
|
Attributes:
|
2020-05-15 04:52:09 +09:00
|
|
|
|
id (:obj:`str`): Уникальный идентификатор тега.
|
2020-05-15 04:44:57 +09:00
|
|
|
|
value (:obj:`str`): Значение тега (название в lower case).
|
|
|
|
|
name (:obj:`str`): Название тега (отображаемое).
|
|
|
|
|
og_description (:obj:`str`): Описание тега для OpenGraph.
|
2020-06-14 21:09:50 +09:00
|
|
|
|
og_image (:obj:`str`, optional): Ссылка на изображение для OpenGraph.
|
2020-05-15 04:44:57 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
|
|
|
|
"""
|
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
id: str
|
|
|
|
|
value: str
|
|
|
|
|
name: str
|
|
|
|
|
og_description: str
|
|
|
|
|
og_image: Optional[str] = None
|
|
|
|
|
client: Optional['Client'] = None
|
2020-06-14 21:09:50 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
def __post_init__(self):
|
2021-02-03 21:28:10 +09:00
|
|
|
|
self._id_attrs = (self.id,)
|
2020-05-15 04:44:57 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['Tag']:
|
|
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`dict`): Поля и значения десериализуемого объекта.
|
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`yandex_music.Tag`: Тег.
|
|
|
|
|
"""
|
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(Tag, cls).de_json(data, client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
2022-02-20 02:59:53 +09:00
|
|
|
|
|
|
|
|
|
# TODO (MarshalX) add download_og_image shortcut?
|
2022-11-01 00:12:59 +09:00
|
|
|
|
# https://github.com/MarshalX/yandex-music-api/issues/556
|