yandex-music-api/yandex_music/playlist/tag.py

53 行
1.7 KiB
Python
Raw Blame 履歴

このファイルには曖昧(ambiguous)なUnicode文字が含まれています

このファイルには、他の文字と見間違える可能性があるUnicode文字が含まれています。 それが意図的なものと考えられる場合は、この警告を無視して構いません。 それらの文字を表示するにはエスケープボタンを使用します。

from typing import TYPE_CHECKING, Optional
from yandex_music import YandexMusicObject
from yandex_music.utils import model
if TYPE_CHECKING:
from yandex_music import Client
@model
class Tag(YandexMusicObject):
"""Класс, представляющий тег (подборку).
Attributes:
id (:obj:`str`): Уникальный идентификатор тега.
value (:obj:`str`): Значение тега (название в lower case).
name (:obj:`str`): Название тега (отображаемое).
og_description (:obj:`str`): Описание тега для OpenGraph.
og_image (:obj:`str`, optional): Ссылка на изображение для OpenGraph.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
"""
id: str
value: str
name: str
og_description: str
og_image: Optional[str] = None
client: Optional['Client'] = None
def __post_init__(self):
self._id_attrs = (self.id,)
@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)
# TODO (MarshalX) add download_og_image shortcut?
# https://github.com/MarshalX/yandex-music-api/issues/556