2019-12-28 22:25:09 +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
|
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, Best
|
|
|
|
|
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 Suggestions(YandexMusicObject):
|
2020-01-27 18:37:11 +09:00
|
|
|
"""Класс, представляющий подсказки при поиске.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
Attributes:
|
2020-03-22 06:29:34 +09:00
|
|
|
best (:obj:`yandex_music.Best`): Лучший результат.
|
2020-01-27 18:37:11 +09:00
|
|
|
suggestions (:obj:`list` из :obj:`str`): Список подсказок-дополнений для поискового запроса.
|
Удаление избыточной информации (#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
|
|
|
best: Optional['Best']
|
|
|
|
suggestions: List[str]
|
|
|
|
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.best, self.suggestions)
|
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
|
|
|
|
|
|
|
def __getitem__(self, item):
|
2019-11-10 03:11:43 +09:00
|
|
|
return self.suggestions[item]
|
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
|
|
|
|
|
|
|
def __iter__(self):
|
2019-11-10 03:11:43 +09:00
|
|
|
return iter(self.suggestions)
|
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') -> Optional['Suggestions']:
|
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.Suggestions`: Подсказки при поиске.
|
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(Suggestions, cls).de_json(data, client)
|
|
|
|
from yandex_music import Best
|
2021-02-03 21:28:10 +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
|
|
|
data['best'] = Best.de_json(data.get('best'), client)
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|