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 datetime import datetime
|
|
|
|
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
|
|
|
|
|
|
class Playlist(YandexMusicObject):
|
|
|
|
def __init__(self,
|
|
|
|
owner,
|
|
|
|
uid,
|
|
|
|
kind,
|
|
|
|
title,
|
|
|
|
track_count,
|
|
|
|
cover,
|
|
|
|
made_for,
|
|
|
|
play_counter,
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
tags=None,
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
revision=None,
|
|
|
|
snapshot=None,
|
|
|
|
visibility=None,
|
|
|
|
collective=None,
|
|
|
|
created=None,
|
|
|
|
modified=None,
|
|
|
|
available=None,
|
|
|
|
is_banner=None,
|
|
|
|
is_premiere=None,
|
|
|
|
duration_ms=None,
|
|
|
|
og_image=None,
|
2019-06-01 17:23:28 +09:00
|
|
|
tracks=None,
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
prerolls=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
|
|
|
likes_count=None,
|
|
|
|
generated_playlist_type=None,
|
|
|
|
animated_cover_uri=None,
|
|
|
|
ever_played=None,
|
|
|
|
description=None,
|
|
|
|
description_formatted=None,
|
|
|
|
is_for_from=None,
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
regions=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.owner = owner
|
|
|
|
self.uid = uid
|
|
|
|
self.kind = kind
|
|
|
|
self.title = title
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
self.track_count = track_count
|
|
|
|
self.cover = cover
|
|
|
|
self.made_for = made_for
|
|
|
|
self.play_counter = play_counter
|
|
|
|
|
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.revision = revision
|
|
|
|
self.snapshot = snapshot
|
|
|
|
self.visibility = visibility
|
|
|
|
self.collective = collective
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
self.created = datetime.fromisoformat(created) if created else created
|
|
|
|
self.modified = datetime.fromisoformat(modified) if modified else modified
|
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.available = available
|
|
|
|
self.is_banner = is_banner
|
|
|
|
self.is_premiere = is_premiere
|
|
|
|
self.duration_ms = duration_ms
|
|
|
|
self.og_image = og_image
|
2019-06-01 17:23:28 +09:00
|
|
|
self.tracks = tracks
|
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.prerolls = prerolls
|
|
|
|
self.likes_count = likes_count
|
|
|
|
self.animated_cover_uri = animated_cover_uri
|
|
|
|
self.description = description
|
|
|
|
self.description_formatted = description_formatted
|
|
|
|
self.ever_played = ever_played
|
|
|
|
self.generated_playlist_type = generated_playlist_type
|
|
|
|
self.is_for_from = is_for_from
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
self.regions = regions
|
New supported objects: Landing, Block, BlockEntity, Chart, ChartItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShorOld (YEAH!)
The following method are wrapped:
- /landing3
Added the ability to download covers
The following field are optional: Playlist.tags
Now, when parsing json, the "client" key is replaced with "client_"
2019-05-25 02:10:39 +09:00
|
|
|
self.tags = tags
|
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
|
|
|
|
self._id_attrs = (self.uid,)
|
|
|
|
|
2019-06-01 15:04:15 +09:00
|
|
|
@property
|
|
|
|
def is_mine(self):
|
|
|
|
return self.owner.uid == self.client.account.uid
|
|
|
|
|
2019-05-19 05:59:14 +09:00
|
|
|
@property
|
|
|
|
def playlist_id(self):
|
|
|
|
return f'{self.owner.uid}:{self.kind}'
|
|
|
|
|
2019-06-01 15:04:15 +09:00
|
|
|
def rename(self, name):
|
|
|
|
client, kind = self.client, self.kind
|
|
|
|
|
|
|
|
self.__dict__.clear()
|
|
|
|
self.__dict__.update(client.users_playlists_name(kind, name).__dict__)
|
|
|
|
|
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):
|
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
|
|
|
data = super(Playlist, cls).de_json(data, client)
|
2019-06-01 17:23:28 +09:00
|
|
|
from yandex_music import User, MadeFor, Cover, PlayCounter, 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
|
|
|
data['owner'] = User.de_json(data.get('owner'), client)
|
|
|
|
data['cover'] = Cover.de_json(data.get('cover'), client)
|
|
|
|
data['made_for'] = MadeFor.de_json(data.get('made_for'), client)
|
2019-06-01 17:23:28 +09:00
|
|
|
data['tracks'] = TrackShort.de_list(data.get('tracks'), client)
|
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
|
|
|
data['play_counter'] = PlayCounter.de_json(data.get('play_counter'), client)
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def de_list(cls, data, client):
|
|
|
|
if not data:
|
|
|
|
return []
|
|
|
|
|
|
|
|
playlists = list()
|
|
|
|
for playlist in data:
|
|
|
|
playlists.append(cls.de_json(playlist, client))
|
|
|
|
|
|
|
|
return playlists
|