예제 #1
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['BriefInfo']:
        """Десериализация объекта.

        Args:
            data (:obj:`dict`): Поля и значения десериализуемого объекта.
            client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.

        Returns:
            :obj:`yandex_music.BriefInfo`: Информация об артисте.
        """
        if not data:
            return None

        data = super(BriefInfo, cls).de_json(data, client)
        from yandex_music import Artist, Track, Album, Cover, PlaylistId, Video, Chart, Vinyl, Playlist

        data['playlists'] = Playlist.de_list(data.get('playlists'), client)
        data['artist'] = Artist.de_json(data.get('artist'), client)
        data['similar_artists'] = Artist.de_list(data.get('similar_artists'),
                                                 client)
        data['popular_tracks'] = Track.de_list(data.get('popular_tracks'),
                                               client)
        data['albums'] = Album.de_list(data.get('albums'), client)
        data['also_albums'] = Album.de_list(data.get('also_albums'), client)
        data['last_releases'] = Album.de_list(data.get('last_releases'),
                                              client)
        data['all_covers'] = Cover.de_list(data.get('all_covers'), client)
        data['playlist_ids'] = PlaylistId.de_list(data.get('playlist_ids'),
                                                  client)
        data['videos'] = Video.de_list(data.get('videos'), client)
        data['tracks_in_chart'] = Chart.de_list(data.get('tracks_in_chart'),
                                                client)
        data['vinyls'] = Vinyl.de_list(data.get('vinyls'), client)

        return cls(client=client, **data)
예제 #2
0
    def de_json(cls, data, client):
        """Десериализация объекта.

        Args:
            data (:obj:`dict`): Поля и значения десериализуемого объекта.
            client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
                Music.

        Returns:
            :obj:`yandex_music.BriefInfo`: Объект класса :class:`yandex_music.BriefInfo`.
        """

        if not data:
            return None

        data = super(BriefInfo, cls).de_json(data, client)
        from yandex_music import Artist, Track, Album, Cover, PlaylistId, Video, Chart, Vinyl
        data['artist'] = Artist.de_json(data.get('artist'), client)
        data['popular_tracks'] = Track.de_list(data.get('popular_tracks'),
                                               client)
        data['albums'] = Album.de_list(data.get('albums'), client)
        data['also_albums'] = Album.de_list(data.get('also_albums'), client)
        data['all_covers'] = Cover.de_list(data.get('all_covers'), client)
        data['playlist_ids'] = PlaylistId.de_list(data.get('playlist_ids'),
                                                  client)
        data['videos'] = Video.de_list(data.get('videos'), client)
        data['tracks_in_chart'] = Chart.de_list(data.get('tracks_in_chart'),
                                                client)
        data['vinyls'] = Vinyl.de_list(data.get('vinyls'), client)

        return cls(client=client, **data)
예제 #3
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(VideoSearchResult, cls).de_json(data, client)
        from yandex_music import Video
        data['results'] = Video.de_list(data.get('results'), client)

        return cls(client=client, **data)
예제 #4
0
 def test_de_list_none(self, client):
     assert Video.de_list({}, client) == []