2019-12-27 18:14:51 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from yandex_music import Client
|
|
|
|
|
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Chart(YandexMusicObject):
|
|
|
|
|
def __init__(self,
|
|
|
|
|
position,
|
|
|
|
|
progress,
|
|
|
|
|
listeners,
|
|
|
|
|
shift,
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
track_id=None,
|
2019-12-27 18:14:51 +09:00
|
|
|
|
client: Optional['Client'] = None,
|
|
|
|
|
**kwargs) -> None:
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
|
self.position = position
|
|
|
|
|
self.progress = progress
|
|
|
|
|
self.listeners = listeners
|
|
|
|
|
self.shift = shift
|
|
|
|
|
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
self.track_id = track_id
|
|
|
|
|
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
|
self.client = client
|
2019-11-10 03:11:43 +09:00
|
|
|
|
self._id_attrs = (self.position, self.progress, self.listeners, self.shift, self.track_id)
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
2019-12-27 18:14:51 +09:00
|
|
|
|
def de_json(cls, data: dict, client: 'Client'):
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`dict`): Поля и значения десериализуемого объекта.
|
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`yandex_music.Chart`: Объект класса :class:`yandex_music.Chart`.
|
|
|
|
|
"""
|
|
|
|
|
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(Chart, cls).de_json(data, client)
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
from yandex_music import TrackId
|
|
|
|
|
data['track_id'] = TrackId.de_json(data.get('track_id'), client)
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
2019-12-27 18:14:51 +09:00
|
|
|
|
def de_list(cls, data: dict, client: 'Client'):
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`list` из :obj:`yandex_music.Chart`: Список объектов класса :class:`yandex_music.Chart`.
|
|
|
|
|
"""
|
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
charts = list()
|
|
|
|
|
for chart in data:
|
|
|
|
|
charts.append(cls.de_json(chart, client))
|
|
|
|
|
|
|
|
|
|
return charts
|