Добавлены тайп хинты для Suggestions, SearchResult, Search, Best, Value, StationResult, Station, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, Dashboard, AdParams
2019-12-27 22:06:24 +09:00
|
|
|
from typing import TYPE_CHECKING, Optional, Union
|
2019-12-27 18:14:51 +09:00
|
|
|
|
2020-12-02 16:55:38 +09:00
|
|
|
from yandex_music import YandexMusicObject, Artist, Album, Track, Playlist, Video, User
|
2021-09-19 22:47:19 +09:00
|
|
|
from yandex_music.utils import model
|
2020-01-26 21:19:22 +09:00
|
|
|
|
2019-12-27 18:14:51 +09:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from yandex_music import Client
|
|
|
|
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
|
|
|
de_json_result = {
|
|
|
|
'track': Track.de_json,
|
|
|
|
'artist': Artist.de_json,
|
|
|
|
'album': Album.de_json,
|
|
|
|
'playlist': Playlist.de_json,
|
|
|
|
'video': Video.de_json,
|
2020-12-02 16:55:38 +09:00
|
|
|
'user': User.de_json,
|
|
|
|
'podcast': Album.de_json,
|
|
|
|
'podcast_episode': Track.de_json,
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
@model
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
class Best(YandexMusicObject):
|
2020-01-27 18:32:31 +09:00
|
|
|
"""Класс, представляющий лучший результат поиска.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
Attributes:
|
2020-01-27 18:32:31 +09:00
|
|
|
type (:obj:`str`): Тип лучшего результата.
|
|
|
|
result (:obj:`yandex_music.Track` | :obj:`yandex_music.Artist` | :obj:`yandex_music.Album` \
|
|
|
|
| :obj:`yandex_music.Playlist` | :obj:`yandex_music.Video`): Лучший результат.
|
|
|
|
text (:obj:`str`, optional): TODO.
|
Удаление избыточной информации (#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
|
|
|
"""
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
type: str
|
|
|
|
result: Optional[Union[Track, Artist, Album, Playlist, Video]]
|
|
|
|
text: Optional[str] = None
|
|
|
|
client: Optional['Client'] = None
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
def __post_init__(self):
|
2019-11-10 03:11:43 +09:00
|
|
|
self._id_attrs = (self.type, self.result)
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
|
|
|
@classmethod
|
2020-01-26 22:17:09 +09:00
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['Best']:
|
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
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.Best`: Лучший результат.
|
2020-01-26 22:17:09 +09:00
|
|
|
"""
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
|
|
|
data = super(Best, cls).de_json(data, client)
|
2021-09-19 22:47:19 +09:00
|
|
|
data['result'] = de_json_result.get(data.get('type'))(data.get('result'), client)
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
|
|
|
return cls(client=client, **data)
|