示例#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 async_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['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: dict, client: 'Client') -> Optional['Album']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Album`: Альбом.
        """
        if not data:
            return None

        data = super(Album, cls).de_json(data, client)
        from async_yandex_music import Artist, Label, TrackPosition, Track
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['labels'] = Label.de_list(data.get('labels'), client)
        data['track_position'] = TrackPosition.de_json(
            data.get('track_position'), client)
        data['duplicates'] = Album.de_list(data.get('duplicates'), client)
        if data.get('volumes'):
            data['volumes'] = [
                Track.de_list(i, client) for i in data['volumes']
            ]

        return cls(client=client, **data)
示例#3
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Artist']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Artist`: Исполнитель.
        """
        if not data:
            return None

        data = super(Artist, cls).de_json(data, client)
        from async_yandex_music import Cover, Ratings, Counts, Link, Track, Description
        data['cover'] = Cover.de_json(data.get('cover'), client)
        data['ratings'] = Ratings.de_json(data.get('ratings'), client)
        data['counts'] = Counts.de_json(data.get('counts'), client)
        data['links'] = Link.de_list(data.get('links'), client)
        data['popular_tracks'] = Track.de_list(data.get('popular_tracks'),
                                               client)
        data['description'] = Description.de_json(data.get('description'),
                                                  client)

        # Мне очень интересно увидеть как в яндухе на клиентах солвят свой бэковский костыль, пригласите на экскурсию
        if data.get('decomposed'):
            data['decomposed'] = [
                Artist.de_json(part, client)
                if isinstance(part, dict) else part
                for part in data['decomposed']
            ]

        return cls(client=client, **data)
示例#4
0
    def de_json(cls, data: dict,
                client: 'Client') -> Optional['SimilarTracks']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.SimilarTracks`: Список похожих треков на другой трек.
        """
        if not data:
            return None

        data = super(SimilarTracks, cls).de_json(data, client)
        from async_yandex_music import Track
        data['track'] = Track.de_json(data.get('track'), client)
        data['similar_tracks'] = Track.de_list(data.get('similar_tracks'),
                                               client)

        return cls(client=client, **data)
    def de_json(cls, data: dict, client: 'Client') -> Optional['TrackWithAds']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.TrackWithAds`: Трек с рекламой.
        """
        if not data:
            return None

        data = super(TrackWithAds, cls).de_json(data, client)
        from async_yandex_music import Track
        data['track'] = Track.de_json(data.get('track'), client)

        return cls(client=client, **data)
    def de_json(cls, data: dict, client: 'Client') -> Optional['PlaylistRecommendations']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.PlaylistRecommendations`: Рекомендации для плейлиста.
        """
        if not data:
            return None

        data = super(PlaylistRecommendations, cls).de_json(data, client)
        from async_yandex_music import Track
        data['tracks'] = Track.de_list(data.get('tracks'), client)

        return cls(client=client, **data)
    def de_json(cls, data: dict, client: 'Client') -> Optional['Sequence']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Sequence`: Звено последовательности.
        """
        if not data:
            return None

        data = super(Sequence, cls).de_json(data, client)
        from async_yandex_music import Track
        data['track'] = Track.de_json(data.get('track'), client)

        return cls(client=client, **data)
示例#8
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['ChartItem']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.ChartItem`: Трек в чарте.
        """
        if not data:
            return None

        data = super(ChartItem, cls).de_json(data, client)
        from async_yandex_music import Chart, Track
        data['track'] = Track.de_json(data.get('track'), client)
        data['chart'] = Chart.de_json(data.get('chart'), client)

        return cls(client=client, **data)
示例#9
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['TrackShort']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.TrackShort`: Укороченная версия трека с неполными данными.
        """
        if not data:
            return None

        data = super(TrackShort, cls).de_json(data, client)
        from async_yandex_music import Track, Chart
        data['track'] = Track.de_json(data.get('track'), client)
        data['chart'] = Chart.de_json(data.get('chart'), client)

        return cls(client=client, **data)
    def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistTracks']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.ArtistsTracks`: Страница списка треков артиста.
        """
        if not data:
            return None

        data = super(ArtistTracks, cls).de_json(data, client)
        from async_yandex_music import Track, Pager
        data['tracks'] = Track.de_list(data.get('tracks'), client)
        data['pager'] = Pager.de_json(data.get('pager'), client)

        return cls(client=client, **data)
示例#11
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['AlbumEvent']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.AlbumEvent`: Альбом в событии фида.
        """
        if not data:
            return None

        data = super(AlbumEvent, cls).de_json(data, client)
        from async_yandex_music import Album, Track
        data['album'] = Album.de_json(data.get('album'), client)
        data['tracks'] = Track.de_list(data.get('tracks'), client)

        return cls(client=client, **data)
    def de_json(cls, data: dict, client: 'Client') -> Optional['ArtistEvent']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.ArtistEvent`: Артист из события фида.
        """
        if not data:
            return None

        data = super(ArtistEvent, cls).de_json(data, client)
        from async_yandex_music import Artist, Track
        data['artist'] = Artist.de_json(data.get('artist'), client)
        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)
示例#13
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Day']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Day`: День в фиде.
        """
        if not data:
            return None

        data = super(Day, cls).de_json(data, client)
        from async_yandex_music import Event, Track, TrackWithAds
        data['events'] = Event.de_list(data.get('events'), client)
        data['tracks_to_play_with_ads'] = TrackWithAds.de_list(
            data.get('tracks_to_play_with_ads'), client)
        data['tracks_to_play'] = Track.de_list(data.get('tracks_to_play'),
                                               client)

        return cls(client=client, **data)