Добавлены тайп хинты для 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 typing import TYPE_CHECKING, Optional, List, Union
|
2019-12-27 18:14:51 +09:00
|
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
|
from yandex_music import YandexMusicObject, Promotion, Album, Playlist, MixLink, PlayContext, ChartItem, \
|
2019-08-18 18:54:13 +09:00
|
|
|
|
GeneratedPlaylist
|
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-01-26 21:19:22 +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
|
|
|
|
|
|
|
|
|
de_json = {
|
|
|
|
|
'personal-playlist': GeneratedPlaylist.de_json,
|
|
|
|
|
'promotion': Promotion.de_json,
|
|
|
|
|
'album': Album.de_json,
|
|
|
|
|
'playlist': Playlist.de_json,
|
|
|
|
|
'chart-item': ChartItem.de_json,
|
|
|
|
|
'play-context': PlayContext.de_json,
|
|
|
|
|
'mix-link': MixLink.de_json
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlockEntity(YandexMusicObject):
|
2020-01-26 23:50:54 +09:00
|
|
|
|
"""Класс, представляющий .
|
|
|
|
|
|
|
|
|
|
Attributes:
|
2020-03-22 08:04:39 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`): Клиент Yandex Music.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
|
|
Args:
|
Удаление избыточной информации (#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,
|
2019-12-28 22:25:09 +09:00
|
|
|
|
id_: str,
|
Добавлены тайп хинты для 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
|
|
|
|
type_: str,
|
|
|
|
|
data: Optional[Union['GeneratedPlaylist', 'Promotion', 'Album',
|
|
|
|
|
'Playlist', 'ChartItem', 'PlayContext', 'MixLink']],
|
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
|
|
|
|
|
2019-12-27 04:51:29 +09:00
|
|
|
|
self.id = id_
|
|
|
|
|
self.type = type_
|
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.data = data
|
|
|
|
|
|
|
|
|
|
self.client = client
|
2019-11-10 05:59:22 +09:00
|
|
|
|
self._id_attrs = (self.id, self.type, self.data)
|
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['BlockEntity']:
|
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 06:29:34 +09:00
|
|
|
|
:obj:`yandex_music.BlockEntity`: TODO.
|
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(BlockEntity, cls).de_json(data, client)
|
2019-12-27 04:51:29 +09:00
|
|
|
|
data['data'] = de_json.get(data.get('type_'))(data.get('data'), 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)
|
|
|
|
|
|
|
|
|
|
@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_list(cls, data: dict, client: 'Client') -> List['BlockEntity']:
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
Удаление избыточной информации (#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 06:29:34 +09:00
|
|
|
|
:obj:`list` из :obj:`yandex_music.BlockEntity`: TODO.
|
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 []
|
|
|
|
|
|
|
|
|
|
entities = list()
|
|
|
|
|
for entity in data:
|
|
|
|
|
entities.append(cls.de_json(entity, client))
|
|
|
|
|
|
|
|
|
|
return entities
|