yandex-music-api/yandex_music/artist/vinyl.py

64 行
2.0 KiB
Python
Raw Blame 履歴

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

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

from yandex_music import YandexMusicObject
class Vinyl(YandexMusicObject):
def __init__(self,
url,
picture,
title,
year,
price,
media,
client=None,
**kwargs):
self.url = url
self.picture = picture
self.title = title
self.year = year
self.price = price
self.media = media
self.client = client
self._id_attrs = (self.title, self.price, self.year, self.url, self.price, self.media)
@classmethod
def de_json(cls, data, client):
"""Десериализация объекта.
Args:
data (:obj:`dict`): Поля и значения десериализуемого объекта.
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
Music.
Returns:
:obj:`yandex_music.Vinyl`: Объект класса :class:`yandex_music.Vinyl`.
"""
if not data:
return None
data = super(Vinyl, cls).de_json(data, client)
return cls(client=client, **data)
@classmethod
def de_list(cls, data, client):
"""Десериализация списка объектов.
Args:
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
Music.
Returns:
:obj:`list` из :obj:`yandex_music.Vinyl`: Список объектов класса :class:`yandex_music.Vinyl`.
"""
if not data:
return []
vinyls = list()
for vinyl in data:
vinyls.append(cls.de_json(vinyl, client))
return vinyls