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 Album(YandexMusicObject):
|
|
|
|
|
def __init__(self,
|
|
|
|
|
id,
|
|
|
|
|
title,
|
|
|
|
|
track_count,
|
|
|
|
|
artists,
|
|
|
|
|
labels,
|
|
|
|
|
available,
|
|
|
|
|
available_for_premium_users,
|
2019-11-08 06:37:53 +09:00
|
|
|
|
cover_uri=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
|
|
|
|
content_warning=None,
|
|
|
|
|
original_release_year=None,
|
|
|
|
|
genre=None,
|
|
|
|
|
og_image=None,
|
|
|
|
|
buy=None,
|
|
|
|
|
recent=None,
|
|
|
|
|
very_important=None,
|
|
|
|
|
available_for_mobile=None,
|
|
|
|
|
available_partially=None,
|
|
|
|
|
bests=None,
|
2019-08-28 04:07:42 +09:00
|
|
|
|
prerolls=None,
|
|
|
|
|
volumes=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
|
|
|
|
year=None,
|
|
|
|
|
release_date=None,
|
2019-05-16 04:38:39 +09:00
|
|
|
|
type=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
|
|
|
|
track_position=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.id = id
|
|
|
|
|
self.title = title
|
|
|
|
|
self.track_count = track_count
|
|
|
|
|
self.artists = artists
|
|
|
|
|
self.labels = labels
|
|
|
|
|
self.available_for_premium_users = available_for_premium_users
|
|
|
|
|
self.available = available
|
|
|
|
|
|
2019-11-08 06:37:53 +09:00
|
|
|
|
self.cover_uri = cover_uri
|
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.genre = genre
|
|
|
|
|
self.year = year
|
2019-11-08 04:52:26 +09:00
|
|
|
|
self.release_date = release_date
|
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.bests = bests
|
2019-08-28 04:07:42 +09:00
|
|
|
|
self.prerolls = prerolls
|
|
|
|
|
self.volumes = volumes
|
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.og_image = og_image
|
|
|
|
|
self.buy = buy
|
|
|
|
|
self.recent = recent
|
|
|
|
|
self.very_important = very_important
|
|
|
|
|
self.available_for_mobile = available_for_mobile
|
|
|
|
|
self.available_partially = available_partially
|
2019-05-16 04:38:39 +09:00
|
|
|
|
self.type = type
|
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.track_position = track_position
|
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
|
|
|
|
|
self.original_release_year = original_release_year
|
|
|
|
|
self.content_warning = content_warning
|
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-10 03:11:43 +09:00
|
|
|
|
self._id_attrs = (self.id, self.title, self.track_count, self.artists, self.labels,
|
|
|
|
|
self.available_for_premium_users, self.available)
|
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-08-28 04:07:42 +09:00
|
|
|
|
def with_tracks(self, *args, **kwargs):
|
|
|
|
|
"""Сокращение для::
|
|
|
|
|
|
|
|
|
|
client.albums_with_tracks(album.id, *args, **kwargs)
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return self.client.albums_with_tracks(self.id, *args, **kwargs)
|
|
|
|
|
|
2019-08-18 23:44:46 +09:00
|
|
|
|
def download_cover(self, filename, size='200x200'):
|
|
|
|
|
"""Загрузка обложки.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
filename (:obj:`str`): Путь для сохранения файла с названием и расширением.
|
|
|
|
|
size (:obj:`str`, optional): Размер обложки.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
self.client.request.download(f'https://{self.cover_uri.replace("%%", size)}', filename)
|
|
|
|
|
|
|
|
|
|
def download_og_image(self, filename, size='200x200'):
|
|
|
|
|
"""Загрузка обложки.
|
|
|
|
|
|
|
|
|
|
Предпочтительнее использовать self.download_cover().
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
filename (:obj:`str`): Путь для сохранения файла с названием и расширением.
|
|
|
|
|
size (:obj:`str`, optional): Размер обложки.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
self.client.request.download(f'https://{self.og_image("%%", size)}', filename)
|
|
|
|
|
|
2019-10-07 02:06:28 +09:00
|
|
|
|
def like(self, *args, **kwargs):
|
|
|
|
|
"""Сокращение для::
|
|
|
|
|
|
|
|
|
|
client.users_likes_albums_add(album.id, user.id *args, **kwargs)
|
|
|
|
|
"""
|
|
|
|
|
return self.client.users_likes_albums_add(self.id, self.client.account.uid, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
def dislike(self, *args, **kwargs):
|
|
|
|
|
"""Сокращение для::
|
|
|
|
|
|
|
|
|
|
client.users_likes_albums_remove(album.id, user.id *args, **kwargs)
|
|
|
|
|
"""
|
|
|
|
|
return self.client.users_likes_albums_remove(self.id, self.client.account.uid, *args, **kwargs)
|
|
|
|
|
|
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(Album, cls).de_json(data, client)
|
2019-08-28 04:07:42 +09:00
|
|
|
|
from yandex_music import Artist, Label, TrackPosition, 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
|
|
|
|
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)
|
2019-08-28 04:07:42 +09:00
|
|
|
|
if data.get('volumes'):
|
|
|
|
|
data['volumes'] = [Track.de_list(i, client) for i in data['volumes']]
|
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
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def de_list(cls, data, client):
|
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
albums = list()
|
|
|
|
|
for album in data:
|
|
|
|
|
albums.append(cls.de_json(album, client))
|
|
|
|
|
|
|
|
|
|
return albums
|
2019-08-18 23:44:46 +09:00
|
|
|
|
|
|
|
|
|
# camelCase псевдонимы
|
|
|
|
|
|
2019-10-19 17:55:45 +09:00
|
|
|
|
#: Псевдоним для :attr:`with_tracks`
|
2019-08-28 04:07:42 +09:00
|
|
|
|
withTracks = with_tracks
|
2019-10-19 17:55:45 +09:00
|
|
|
|
#: Псевдоним для :attr:`download_cover`
|
2019-08-18 23:44:46 +09:00
|
|
|
|
downloadCover = download_cover
|
2019-10-19 17:55:45 +09:00
|
|
|
|
#: Псевдоним для :attr:`download_og_image`
|
2019-08-18 23:44:46 +09:00
|
|
|
|
downloadOgImage = download_og_image
|