Добавлены тайп хинты для 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
|
|
|
|
|
|
|
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
|
|
|
from yandex_music import YandexMusicObject, Artist, Album, Track, Playlist, Video
|
|
|
|
|
|
|
|
|
|
|
|
de_json_result = {
|
|
|
|
'track': Track.de_json,
|
|
|
|
'artist': Artist.de_json,
|
|
|
|
'album': Album.de_json,
|
|
|
|
'playlist': Playlist.de_json,
|
|
|
|
'video': Video.de_json,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Best(YandexMusicObject):
|
|
|
|
def __init__(self,
|
Добавлены тайп хинты для Suggestions, SearchResult, Search, Best, Value, StationResult, Station, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, Dashboard, AdParams
2019-12-27 22:06:24 +09:00
|
|
|
type_: str,
|
|
|
|
result: Optional[Union[Track, Artist, Album, Playlist, Video]],
|
|
|
|
text: 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.type = type_
|
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
|
|
|
self.result = result
|
|
|
|
|
|
|
|
self.text = text
|
|
|
|
|
|
|
|
self.client = client
|
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
|
2019-12-27 18:14:51 +09:00
|
|
|
def de_json(cls, data: dict, client: '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
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
|
|
|
data = super(Best, cls).de_json(data, client)
|
2019-12-27 04:51:29 +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)
|