2019-12-27 18:14:51 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
|
|
|
|
|
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:
|
Добавлены тайп хинты для Suggestions, SearchResult, Search, Best, Value, StationResult, Station, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, Dashboard, AdParams
2019-12-27 22:06:24 +09:00
|
|
|
|
from yandex_music import Client, Track
|
2019-12-27 18:14:51 +09:00
|
|
|
|
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
@model
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
class Sequence(YandexMusicObject):
|
2020-03-22 09:48:04 +09:00
|
|
|
|
"""Класс, представляющий звено последовательности.
|
|
|
|
|
|
|
|
|
|
Note:
|
|
|
|
|
Известные значения поля `type_`: `track`. Возможно есть `ad`.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
|
|
Attributes:
|
2021-09-19 22:47:19 +09:00
|
|
|
|
type (:obj:`str`): Тип звена.
|
2020-03-22 09:48:04 +09:00
|
|
|
|
track (:obj:`yandex_music.Track` | :obj:`None`): Трек.
|
|
|
|
|
liked (:obj:`bool`): Связанное ли.
|
Удаление избыточной информации (#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
|
|
|
|
type: str
|
|
|
|
|
track: Optional['Track']
|
|
|
|
|
liked: bool
|
|
|
|
|
client: Optional['Client'] = None
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
def __post_init__(self):
|
Добавлены основные тесты для следующих классов: 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
|
|
|
|
self._id_attrs = (self.type, self.track, self.liked)
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
Добавлены тайп хинты для Suggestions, SearchResult, Search, Best, Value, StationResult, Station, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, Dashboard, AdParams
2019-12-27 22:06:24 +09:00
|
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['Sequence']:
|
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 09:48:04 +09:00
|
|
|
|
:obj:`yandex_music.Sequence`: Звено последовательности.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(Sequence, cls).de_json(data, client)
|
|
|
|
|
from yandex_music import Track
|
2021-02-03 21:28:10 +09:00
|
|
|
|
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
data['track'] = Track.de_json(data.get('track'), client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
Добавлены тайп хинты для Suggestions, SearchResult, Search, Best, Value, StationResult, Station, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, Dashboard, AdParams
2019-12-27 22:06:24 +09:00
|
|
|
|
def de_list(cls, data: dict, client: 'Client') -> List['Sequence']:
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
Удаление избыточной информации (#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 09:48:04 +09:00
|
|
|
|
:obj:`list` из :obj:`yandex_music.Sequence`: Последовательность треков.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""
|
New supported objects: Station, StationResult, StationTrackResult, Value, Sequence, RotorSettings, Restrictions, Id, Enum, DiscreteScale, DashBoard, AdParams
The following methods are wrapped:
- /rotor/account/status
- /rotor/stations/dashboard
- /rotor/stations/list
- /rotor/station/genre:{genre}/feedback
- /rotor/station/genre:{genre}/info
- /rotor/station/genre:{genre}/tracks
The following fields are now optional: Account[region, passport_phones], Status[cache_limit, subeditor, subeditor_level, plus], Subscription[auto_renewable, can_start_trial, mcdonalds]
Added new fields: Subscription.end, Status[skips_per_hour, station_exists, premium_region], Track..preview_duration_ms
Fixed downloading the cover of the track
2019-06-03 22:16:24 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
sequences = list()
|
|
|
|
|
for sequence in data:
|
|
|
|
|
sequences.append(cls.de_json(sequence, client))
|
|
|
|
|
|
|
|
|
|
return sequences
|