2019-12-27 18:14:51 +09:00
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
from yandex_music import Client, Artist, Track
|
2019-12-27 18:14:51 +09:00
|
|
|
|
2019-05-16 04:38:39 +09:00
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
|
|
|
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 ArtistEvent(YandexMusicObject):
|
2019-05-16 04:38:39 +09:00
|
|
|
def __init__(self,
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
artist: Optional['Artist'],
|
|
|
|
tracks: List['Track'],
|
|
|
|
similar_to_artists_from_history: List['Artist'],
|
2019-12-27 18:14:51 +09:00
|
|
|
client: Optional['Client'] = None,
|
|
|
|
**kwargs) -> None:
|
2019-05-16 04:38:39 +09:00
|
|
|
self.artist = artist
|
|
|
|
self.tracks = tracks
|
|
|
|
self.similar_to_artists_from_history = similar_to_artists_from_history
|
|
|
|
|
|
|
|
self.client = client
|
2019-11-10 03:11:43 +09:00
|
|
|
self._id_attrs = (self.artist, self.tracks, self.similar_to_artists_from_history)
|
2019-05-16 04:38:39 +09:00
|
|
|
|
|
|
|
@classmethod
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistEvent']:
|
2019-05-16 04:38:39 +09:00
|
|
|
if not data:
|
|
|
|
return 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
|
|
|
data = super(ArtistEvent, cls).de_json(data, client)
|
2019-05-16 04:38:39 +09:00
|
|
|
from yandex_music import Artist, Track
|
Добавлены основные тесты для следующих классов: AlbumEvent, AlbumsLikes, ArtistEvent, ArtistsLikes, ChartItem, Dashboard, Day, Event, Sequence, StationTracksResult, Supplement, TrackWithAds.
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Отрефакторен conftest.py.
Исправлен баг в .to_dict() методе, связанный с не рекурсивной десериализацией объектов списков и словарей.
Исправлен баг с десериализацией artist в классе ArtistEvent
2019-11-09 22:43:02 +09:00
|
|
|
data['artist'] = Artist.de_json(data.get('artist'), client)
|
2019-05-16 04:38:39 +09:00
|
|
|
data['tracks'] = Track.de_list(data.get('tracks'), client)
|
|
|
|
data['similar_to_artists_from_history'] = Artist.de_list(data.get('similar_to_artists_from_history'), client)
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
@classmethod
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
def de_list(cls, data: dict, client: 'Client') -> List['ArtistEvent']:
|
2019-05-16 04:38:39 +09:00
|
|
|
if not data:
|
|
|
|
return []
|
|
|
|
|
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
|
|
|
artist_events = list()
|
|
|
|
for artist_event in data:
|
|
|
|
artist_events.append(cls.de_json(artist_event, client))
|
2019-05-16 04:38:39 +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
|
|
|
return artist_events
|