Example #1
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(Dashboard, cls).de_json(data, client)
        from yandex_music import StationResult
        data['stations'] = StationResult.de_list(data.get('stations'), client)

        return cls(client=client, **data)
Example #2
0
    def rotor_station_genre_info(self,
                                 genre: str,
                                 timeout=None,
                                 *args,
                                 **kwargs):
        url = f'{self.base_url}/rotor/station/genre:{genre}/info'

        result = self._request.get(url, timeout=timeout, *args, **kwargs)

        return StationResult.de_list(result, self)
Example #3
0
    def rotor_stations_list(self,
                            language: str = 'en',
                            timeout=None,
                            *args,
                            **kwargs):
        url = f'{self.base_url}/rotor/stations/list'

        result = self._request.get(url, {'language': language},
                                   timeout=timeout,
                                   *args,
                                   **kwargs)

        return StationResult.de_list(result, self)
Example #4
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Dashboard']:
        """Десериализация объекта.

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

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

        data = super(Dashboard, cls).de_json(data, client)
        from yandex_music import StationResult
        data['stations'] = StationResult.de_list(data.get('stations'), client)

        return cls(client=client, **data)
Example #5
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.Dashboard`: Объект класса :class:`yandex_music.Dashboard`.
        """
        if not data:
            return None

        data = super(Dashboard, cls).de_json(data, client)
        from yandex_music import StationResult
        data['stations'] = StationResult.de_list(data.get('stations'), client)

        return cls(client=client, **data)
Example #6
0
 def test_de_list_none(self, client):
     assert StationResult.de_list({}, client) == []