2019-12-27 18:14:51 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
|
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
2019-12-27 18:14:51 +09:00
|
|
|
|
if TYPE_CHECKING:
|
Добавлены тайп хинты для 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
|
|
|
|
from yandex_music import Client, TrackShortOld
|
2019-12-27 18:14:51 +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
|
|
|
|
|
|
|
|
|
class PlayContext(YandexMusicObject):
|
2020-03-22 12:01:34 +09:00
|
|
|
|
"""Класс, представляющий проигрываемый контекст.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
Известные значения поля `client_`: `android`.
|
|
|
|
|
|
|
|
|
|
Поле `context` хранит в себе место воспроизведения, например, `playlist`.
|
|
|
|
|
|
|
|
|
|
Поле `context_item` хранит в себе уникальный идентификатор context'a, т.е. в нашем случае playlist'a.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
|
|
Attributes:
|
2020-03-22 12:01:34 +09:00
|
|
|
|
client_ (:obj:`str`): Клиент.
|
|
|
|
|
context (:obj:`str`): Тип контекста.
|
|
|
|
|
context_item (:obj:`str`): Предмет контекста.
|
|
|
|
|
tracks (:obj:`list` из :obj:`yandex_music.TrackShortOld`): Треки.
|
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 12:01:34 +09:00
|
|
|
|
client_ (:obj:`str`): Клиент.
|
|
|
|
|
context (:obj:`str`): Тип контекста.
|
|
|
|
|
context_item (:obj:`str`): Предмет контекста.
|
|
|
|
|
tracks (:obj:`list` из :obj:`yandex_music.TrackShortOld`): Треки.
|
Удаление избыточной информации (#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.
|
|
|
|
|
"""
|
|
|
|
|
|
2021-02-03 21:28:10 +09:00
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
client_: str,
|
|
|
|
|
context: str,
|
|
|
|
|
context_item: str,
|
|
|
|
|
tracks: List['TrackShortOld'],
|
|
|
|
|
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.client_ = client_
|
|
|
|
|
self.context = context
|
|
|
|
|
self.context_item = context_item
|
|
|
|
|
self.tracks = tracks
|
2019-11-10 03:11:43 +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
|
|
|
|
self.client = client
|
2019-11-10 03:11:43 +09:00
|
|
|
|
self._id_attrs = (self.client_, self.context_item, self.context_item, self.tracks)
|
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['PlayContext']:
|
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 12:01:34 +09:00
|
|
|
|
:obj:`yandex_music.PlayContext`: Проигрываемый контекст.
|
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(PlayContext, cls).de_json(data, client)
|
|
|
|
|
from yandex_music import TrackShortOld
|
2021-02-03 21:28:10 +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
|
|
|
|
data['tracks'] = TrackShortOld.de_list(data.get('tracks'), client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|