Метод de_list в TrackId.
Поля coauthors и recent_tracks в Playlist.
Поле regions в User.
Поля users, podcasts, podcast_episodes, type_, page, per_page в Search.
Поддержка новых типов поиска: подкасты, выпуски, пользователи.
Поля short_description, description, is_premiere, is_banner в Like.
Документация и тесты к новым поля. #339
2020-06-07 18:55:30 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
2019-12-27 18:14:51 +09:00
|
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
2019-12-27 18:14:51 +09:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
class TrackId(YandexMusicObject):
|
2020-03-22 08:46:59 +09:00
|
|
|
|
"""Класс, представляющий уникальный идентификатор трека.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
2020-06-20 22:54:46 +09:00
|
|
|
|
Note:
|
|
|
|
|
Поле `track_id` используется только у объектах полученных через очередь треков. В остальные случаях `id`.
|
|
|
|
|
|
|
|
|
|
Поле `from_` есть только у объект, которые используются в очереди треков.
|
|
|
|
|
|
2020-01-26 23:50:54 +09:00
|
|
|
|
Attributes:
|
2020-03-22 08:46:59 +09:00
|
|
|
|
id_ (:obj:`int`): Уникальный идентификатор трека.
|
2020-06-20 22:54:46 +09:00
|
|
|
|
track_id (:obj:`int`): Уникальный идентификатор трека.
|
2020-03-22 08:46:59 +09:00
|
|
|
|
album_id (:obj:`int`): Уникальный идентификатор альбома.
|
2020-06-20 22:54:46 +09:00
|
|
|
|
from_ (:obj:`str`): Откуда был получен этот объект.
|
2020-03-22 08:04:39 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`): Клиент Yandex Music.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
|
|
Args:
|
2020-03-22 08:46:59 +09:00
|
|
|
|
id_ (:obj:`int`): Уникальный идентификатор трека.
|
2020-06-20 22:54:46 +09:00
|
|
|
|
track_id (:obj:`int`): Уникальный идентификатор трека.
|
2020-03-22 08:46:59 +09:00
|
|
|
|
album_id (:obj:`int`, optional): Уникальный идентификатор альбома.
|
2020-06-20 22:54:46 +09:00
|
|
|
|
from_ (: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
|
|
|
|
**kwargs: Произвольные ключевые аргументы полученные от API.
|
|
|
|
|
"""
|
|
|
|
|
|
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
|
|
|
|
def __init__(self,
|
2020-06-20 22:54:46 +09:00
|
|
|
|
id_: Optional[int] = None,
|
|
|
|
|
track_id: Optional[int] = None,
|
2019-12-28 22:25:09 +09:00
|
|
|
|
album_id: Optional[int] = None,
|
2020-06-20 22:54:46 +09:00
|
|
|
|
from_: Optional[str] = None,
|
2019-12-27 18:14:51 +09:00
|
|
|
|
client: Optional['Client'] = None,
|
|
|
|
|
**kwargs) -> None:
|
2019-12-27 04:51:29 +09:00
|
|
|
|
self.id = id_
|
2020-06-20 22:54:46 +09:00
|
|
|
|
self.track_id = track_id
|
2019-07-30 01:01:56 +09:00
|
|
|
|
self.album_id = album_id
|
2020-06-20 22:54:46 +09:00
|
|
|
|
self.from_ = from_
|
|
|
|
|
|
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
|
2020-06-20 22:54:46 +09:00
|
|
|
|
self._id_attrs = (self.track_id, self.id, self.album_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
|
|
|
|
|
2020-05-16 04:14:44 +09:00
|
|
|
|
super().handle_unknown_kwargs(self, **kwargs)
|
|
|
|
|
|
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
|
Добавлены тайп хинты для Block, BlockEntity, Char, CharItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShortOld, AlbumsLikes, ArtistsLikes, PlaylistsLikes, CaseForms, MadeFor, PlayCounter, PlaylistAbsence, PlaylistId, User
2019-12-27 22:40:26 +09:00
|
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['TrackId']:
|
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 08:46:59 +09:00
|
|
|
|
:obj:`yandex_music.TrackId`: Уникальный идентификатор трека.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""
|
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(TrackId, cls).de_json(data, client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
Метод de_list в TrackId.
Поля coauthors и recent_tracks в Playlist.
Поле regions в User.
Поля users, podcasts, podcast_episodes, type_, page, per_page в Search.
Поддержка новых типов поиска: подкасты, выпуски, пользователи.
Поля short_description, description, is_premiere, is_banner в Like.
Документация и тесты к новым поля. #339
2020-06-07 18:55:30 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def de_list(cls, data: dict, client: 'Client') -> List['TrackId']:
|
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`list` из :obj:`yandex_music.TrackId`: Уникальные идентификаторы треков.
|
|
|
|
|
"""
|
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
return [cls.de_json(track_id, client) for track_id in data]
|