New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TrackShort(YandexMusicObject):
|
2019-07-05 02:21:54 +09:00
|
|
|
|
"""Класс представляющий укороченную версию трека с неполными данными.
|
|
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
|
id (:obj:`str`): Уникальный идентификатор трека.
|
2019-11-08 04:52:26 +09:00
|
|
|
|
timestamp (:obj:`str`): Дата TODO.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
album_id (:obj:`str`): Уникальный идентификатор альбома.
|
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
id (:obj:`str`): Уникальный идентификатор трека.
|
|
|
|
|
timestamp (:obj:`str`): Дата TODO.
|
|
|
|
|
album_id (:obj:`str`, optional): Уникальный идентификатор альбома.
|
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Объект класса :class:`yandex_music.Client` представляющий клиент
|
|
|
|
|
Yandex Music.
|
|
|
|
|
**kwargs: Произвольные ключевые аргументы полученные от API.
|
|
|
|
|
"""
|
|
|
|
|
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
def __init__(self,
|
|
|
|
|
id,
|
|
|
|
|
timestamp,
|
2019-06-03 00:15:51 +09:00
|
|
|
|
album_id=None,
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
client=None,
|
|
|
|
|
**kwargs):
|
|
|
|
|
self.id = id
|
2019-11-08 04:52:26 +09:00
|
|
|
|
self.timestamp = timestamp
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
|
2019-06-03 00:15:51 +09:00
|
|
|
|
self.album_id = album_id
|
|
|
|
|
|
2019-05-23 18:10:14 +09:00
|
|
|
|
self._track = None
|
|
|
|
|
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
self.client = client
|
2019-11-08 04:52:26 +09:00
|
|
|
|
self._id_attrs = (self.id,)
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
|
2019-05-23 18:10:14 +09:00
|
|
|
|
@property
|
|
|
|
|
def track(self):
|
2019-07-05 02:21:54 +09:00
|
|
|
|
""":obj:`yandex_music.Track`: Объект класса :class:`yandex_music.Track` представляющий полную версию трека."""
|
2019-05-23 18:10:14 +09:00
|
|
|
|
if self._track:
|
|
|
|
|
return self._track
|
|
|
|
|
|
|
|
|
|
self._track = self.client.tracks(self.track_id)[0]
|
|
|
|
|
|
|
|
|
|
return self._track
|
|
|
|
|
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
@property
|
|
|
|
|
def track_id(self):
|
2019-07-17 02:01:51 +09:00
|
|
|
|
""":obj:`str`: Уникальный идентификатор трека состоящий из его номера и номера альбома или просто из номера."""
|
2019-07-05 02:21:54 +09:00
|
|
|
|
|
2019-07-17 02:01:51 +09:00
|
|
|
|
if self.album_id:
|
|
|
|
|
return f'{self.id}:{self.album_id}'
|
|
|
|
|
|
|
|
|
|
return f'{self.id}'
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def de_json(cls, data, client):
|
2019-07-05 02:21:54 +09:00
|
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`dict`): Поля и значения десериализуемого объекта.
|
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`yandex_music.TrackShort`: Объект класса :class:`yandex_music.TrackShort`.
|
|
|
|
|
"""
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(TrackShort, cls).de_json(data, client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def de_list(cls, data, client):
|
2019-07-05 02:21:54 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`list` из :obj:`yandex_music.TrackShort`: Список объектов класса :class:`yandex_music.TrackShort`.
|
|
|
|
|
"""
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
tracks = list()
|
|
|
|
|
for track in data:
|
|
|
|
|
tracks.append(cls.de_json(track, client))
|
|
|
|
|
|
|
|
|
|
return tracks
|
2019-08-18 18:54:13 +09:00
|
|
|
|
|
|
|
|
|
# camelCase псевдонимы
|
|
|
|
|
|
2019-10-19 17:55:45 +09:00
|
|
|
|
#: Псевдоним для :attr:`track_id`
|
2019-08-18 18:54:13 +09:00
|
|
|
|
trackId = track_id
|