deezer-python 5.11.1__py3-none-any.whl → 6.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deezer/__init__.py +1 -1
- deezer/client.py +5 -2
- deezer/resources/resource.py +26 -0
- deezer/resources/user.py +103 -0
- deezer/utils.py +10 -6
- {deezer_python-5.11.1.dist-info → deezer_python-6.0.0.dist-info}/METADATA +2 -3
- {deezer_python-5.11.1.dist-info → deezer_python-6.0.0.dist-info}/RECORD +9 -9
- {deezer_python-5.11.1.dist-info → deezer_python-6.0.0.dist-info}/WHEEL +1 -1
- {deezer_python-5.11.1.dist-info → deezer_python-6.0.0.dist-info}/LICENSE.txt +0 -0
deezer/__init__.py
CHANGED
deezer/client.py
CHANGED
|
@@ -565,9 +565,12 @@ class Client:
|
|
|
565
565
|
Create a playlist on the user's account
|
|
566
566
|
|
|
567
567
|
:param playlist_name: the name of the playlist.
|
|
568
|
-
:return: ID of the
|
|
568
|
+
:return: the ID of the playlist that was created
|
|
569
569
|
"""
|
|
570
|
-
|
|
570
|
+
result = self.request("POST", "user/me/playlists", title=playlist_name)
|
|
571
|
+
# Note: the REST API call returns a dict with just the "id" key in it,
|
|
572
|
+
# so we return that instead of the full Playlist object
|
|
573
|
+
return result.id
|
|
571
574
|
|
|
572
575
|
def delete_playlist(self, playlist_id) -> bool:
|
|
573
576
|
"""
|
deezer/resources/resource.py
CHANGED
|
@@ -71,6 +71,32 @@ class Resource:
|
|
|
71
71
|
**kwargs,
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
+
def post_relation(self, relation, **kwargs):
|
|
75
|
+
"""
|
|
76
|
+
Generic method to make a POST request to a relation from any resource.
|
|
77
|
+
|
|
78
|
+
This is not meant to be used directly by a client, it's more
|
|
79
|
+
a helper method for the child objects.
|
|
80
|
+
"""
|
|
81
|
+
return self.client.request(
|
|
82
|
+
"POST",
|
|
83
|
+
f"{self.type}/{self.id}/{relation}",
|
|
84
|
+
**kwargs,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
def delete_relation(self, relation, **kwargs):
|
|
88
|
+
"""
|
|
89
|
+
Generic method to make a DELETE request to a relation from any resource.
|
|
90
|
+
|
|
91
|
+
This is not meant to be used directly by a client, it's more
|
|
92
|
+
a helper method for the child objects.
|
|
93
|
+
"""
|
|
94
|
+
return self.client.request(
|
|
95
|
+
"DELETE",
|
|
96
|
+
f"{self.type}/{self.id}/{relation}",
|
|
97
|
+
**kwargs,
|
|
98
|
+
)
|
|
99
|
+
|
|
74
100
|
def get_paginated_list(
|
|
75
101
|
self,
|
|
76
102
|
relation: str,
|
deezer/resources/user.py
CHANGED
|
@@ -4,6 +4,7 @@ import datetime as dt
|
|
|
4
4
|
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from ..dates import parse_date
|
|
7
|
+
from ..utils import get_id
|
|
7
8
|
from .resource import Resource
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
@@ -56,6 +57,24 @@ class User(Resource):
|
|
|
56
57
|
"""
|
|
57
58
|
return self.get_paginated_list("albums", **kwargs)
|
|
58
59
|
|
|
60
|
+
def add_album(self, album: Album | int):
|
|
61
|
+
"""
|
|
62
|
+
Add an album to user's favorite albums.
|
|
63
|
+
|
|
64
|
+
:param album: an :class:`~deezer.Album` instance or its ID
|
|
65
|
+
:returns: a boolean that tells if the operation was successful
|
|
66
|
+
"""
|
|
67
|
+
return self.post_relation("albums", album_id=get_id(album))
|
|
68
|
+
|
|
69
|
+
def remove_album(self, album: Album | int):
|
|
70
|
+
"""
|
|
71
|
+
Remove an album from user's favorite albums.
|
|
72
|
+
|
|
73
|
+
:param album: an :class:`~deezer.Album` instance or its ID
|
|
74
|
+
:returns: a boolean that tells if the operation was successful
|
|
75
|
+
"""
|
|
76
|
+
return self.delete_relation("albums", album_id=get_id(album))
|
|
77
|
+
|
|
59
78
|
def get_tracks(self, **kwargs) -> PaginatedList[Track]:
|
|
60
79
|
"""
|
|
61
80
|
Get user's favorite tracks.
|
|
@@ -65,6 +84,24 @@ class User(Resource):
|
|
|
65
84
|
"""
|
|
66
85
|
return self.get_paginated_list("tracks", **kwargs)
|
|
67
86
|
|
|
87
|
+
def add_track(self, track: Track | int):
|
|
88
|
+
"""
|
|
89
|
+
Add a track to user's favorite tracks.
|
|
90
|
+
|
|
91
|
+
:param track: a :class:`~deezer.Track` instance or its ID
|
|
92
|
+
:returns: a boolean that tells if the operation was successful
|
|
93
|
+
"""
|
|
94
|
+
return self.post_relation("tracks", track_id=get_id(track))
|
|
95
|
+
|
|
96
|
+
def remove_track(self, track: Track | int):
|
|
97
|
+
"""
|
|
98
|
+
Remove a track from user's favorite tracks.
|
|
99
|
+
|
|
100
|
+
:param track: a :class:`~deezer.Track` instance or its ID
|
|
101
|
+
:returns: a boolean that tells if the operation was successful
|
|
102
|
+
"""
|
|
103
|
+
return self.delete_relation("tracks", track_id=get_id(track))
|
|
104
|
+
|
|
68
105
|
def get_artists(self, **kwargs) -> PaginatedList[Artist]:
|
|
69
106
|
"""
|
|
70
107
|
Get user's favorite artists.
|
|
@@ -74,6 +111,24 @@ class User(Resource):
|
|
|
74
111
|
"""
|
|
75
112
|
return self.get_paginated_list("artists", **kwargs)
|
|
76
113
|
|
|
114
|
+
def add_artist(self, artist: Artist | int):
|
|
115
|
+
"""
|
|
116
|
+
Add an artist to user's favorite artists.
|
|
117
|
+
|
|
118
|
+
:param artist: an :class:`~deezer.Artist` instance or its ID
|
|
119
|
+
:returns: a boolean that tells if the operation was successful
|
|
120
|
+
"""
|
|
121
|
+
return self.post_relation("artists", artist_id=get_id(artist))
|
|
122
|
+
|
|
123
|
+
def remove_artist(self, artist: Artist | int):
|
|
124
|
+
"""
|
|
125
|
+
Remove an artist from user's favorite artists.
|
|
126
|
+
|
|
127
|
+
:param artist: an :class:`~deezer.Artist` instance or its ID
|
|
128
|
+
:returns: a boolean that tells if the operation was successful
|
|
129
|
+
"""
|
|
130
|
+
return self.delete_relation("artists", artist_id=get_id(artist))
|
|
131
|
+
|
|
77
132
|
def get_followers(self, **kwargs) -> PaginatedList[User]:
|
|
78
133
|
"""
|
|
79
134
|
Get user's followers.
|
|
@@ -92,6 +147,24 @@ class User(Resource):
|
|
|
92
147
|
"""
|
|
93
148
|
return self.get_paginated_list("followings", **kwargs)
|
|
94
149
|
|
|
150
|
+
def follow(self, user: User | int):
|
|
151
|
+
"""
|
|
152
|
+
Follow a user.
|
|
153
|
+
|
|
154
|
+
:param user: a :class:`~deezer.User` instance or its ID
|
|
155
|
+
:returns: a boolean that tells if the operation was successful
|
|
156
|
+
"""
|
|
157
|
+
return self.post_relation("followings", user_id=get_id(user))
|
|
158
|
+
|
|
159
|
+
def unfollow(self, user: User | int):
|
|
160
|
+
"""
|
|
161
|
+
Unfollow a user.
|
|
162
|
+
|
|
163
|
+
:param user: a :class:`~deezer.User` instance or its ID
|
|
164
|
+
:returns: a boolean that tells if the operation was successful
|
|
165
|
+
"""
|
|
166
|
+
return self.delete_relation("followings", user_id=get_id(user))
|
|
167
|
+
|
|
95
168
|
def get_playlists(self, **kwargs) -> PaginatedList[Playlist]:
|
|
96
169
|
"""
|
|
97
170
|
Get user's public playlists.
|
|
@@ -100,3 +173,33 @@ class User(Resource):
|
|
|
100
173
|
of :class:`Playlist <deezer.Playlist>` instances
|
|
101
174
|
"""
|
|
102
175
|
return self.get_paginated_list("playlists", **kwargs)
|
|
176
|
+
|
|
177
|
+
def add_playlist(self, playlist: Playlist | int):
|
|
178
|
+
"""
|
|
179
|
+
Add a playlist to user's public playlists.
|
|
180
|
+
|
|
181
|
+
:param playlist: a :class:`~deezer.Playlist` instance or its ID
|
|
182
|
+
:returns: a boolean that tells if the operation was successful
|
|
183
|
+
"""
|
|
184
|
+
return self.post_relation("playlists", playlist_id=get_id(playlist))
|
|
185
|
+
|
|
186
|
+
def remove_playlist(self, playlist: Playlist | int):
|
|
187
|
+
"""
|
|
188
|
+
Remove a playlist from user's public playlists.
|
|
189
|
+
|
|
190
|
+
:param playlist: a :class:`~deezer.Playlist` instance or its ID
|
|
191
|
+
:returns: a boolean that tells if the operation was successful
|
|
192
|
+
"""
|
|
193
|
+
return self.delete_relation("playlists", playlist_id=get_id(playlist))
|
|
194
|
+
|
|
195
|
+
def create_playlist(self, title: str) -> int:
|
|
196
|
+
"""
|
|
197
|
+
Create a playlist.
|
|
198
|
+
|
|
199
|
+
:param title: the title of the playlist
|
|
200
|
+
:returns: the ID of the playlist that was created
|
|
201
|
+
"""
|
|
202
|
+
result = self.post_relation("playlists", title=title)
|
|
203
|
+
# Note: the REST API call returns a dict with just the "id" key in it,
|
|
204
|
+
# so we return that instead of the full Playlist object
|
|
205
|
+
return result.id
|
deezer/utils.py
CHANGED
|
@@ -9,9 +9,13 @@ if TYPE_CHECKING:
|
|
|
9
9
|
def gen_ids(item_list: Iterable[int | Resource]) -> Generator[int, None, None]:
|
|
10
10
|
"""Get IDs for an iterable of `int` or `Resources`."""
|
|
11
11
|
for item in item_list:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
yield get_id(item)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_id(item: int | Resource) -> int:
|
|
16
|
+
"""Get ID for an `int` or `Resource`."""
|
|
17
|
+
if isinstance(item, int):
|
|
18
|
+
return item
|
|
19
|
+
if hasattr(item, "id"):
|
|
20
|
+
return item.id
|
|
21
|
+
raise NotImplementedError(f"Unknown type for {item}")
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: deezer-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: A friendly wrapper library for the Deezer API
|
|
5
5
|
Home-page: https://github.com/browniebroke/deezer-python
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: deezer,sdk,client,requests
|
|
8
8
|
Author: Bruno Alla
|
|
9
9
|
Author-email: alla.brunoo@gmail.com
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.8,<4.0
|
|
11
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Natural Language :: English
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.8
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
deezer/__init__.py,sha256=
|
|
2
|
-
deezer/client.py,sha256=
|
|
1
|
+
deezer/__init__.py,sha256=0NeTLMTWBprgN9H2xa0pe89alLo8Y9PHixGg7TYDjwc,556
|
|
2
|
+
deezer/client.py,sha256=AgFYYDqe3An7momBuR0JqgkZ-c3JPuRWeO72EWUJQ1k,24840
|
|
3
3
|
deezer/dates.py,sha256=BG8Aj6s0ctiQYmeKXowhNzb9--AeDxpWG82w3gA03NE,530
|
|
4
4
|
deezer/exceptions.py,sha256=gsSYTKfKH8BbLJxptPEZC6yfr4baTQ9_kohIogc_HRo,1864
|
|
5
5
|
deezer/pagination.py,sha256=OWLv_eUHQeLeROVPK9i7GmooUzEQ3nNuP2ID0kv8l9Q,3745
|
|
@@ -13,11 +13,11 @@ deezer/resources/genre.py,sha256=CDWyNyFT3fXQM7jPkz3UtGr8gNtVn9430h11Jl0ZwAc,135
|
|
|
13
13
|
deezer/resources/playlist.py,sha256=8pAMmqUG4S9QLZOX5OrEoj4qA8pggDQBVxbG-DNxqgk,3325
|
|
14
14
|
deezer/resources/podcast.py,sha256=lipRKhlFSXry97l_0xZJHfIxVeOh6VVdL9LhDIHyZbc,914
|
|
15
15
|
deezer/resources/radio.py,sha256=moOdlSJABqCcluInvgbHSwIzSIhDvBQaVyDGdgeVr_0,805
|
|
16
|
-
deezer/resources/resource.py,sha256=
|
|
16
|
+
deezer/resources/resource.py,sha256=cuPXzvcXrsrHTj-UD3c5drhkjRwQ4Dkghik2icwDPGw,4826
|
|
17
17
|
deezer/resources/track.py,sha256=e3DPTsYWq5yNCjMRQhGTrFQHfQUe3xn0mEVYbpL3O_0,1546
|
|
18
|
-
deezer/resources/user.py,sha256=
|
|
19
|
-
deezer/utils.py,sha256=
|
|
20
|
-
deezer_python-
|
|
21
|
-
deezer_python-
|
|
22
|
-
deezer_python-
|
|
23
|
-
deezer_python-
|
|
18
|
+
deezer/resources/user.py,sha256=6-46PX80xEgtCY2FecwzzgbvYu1aL1WShFXcCOaVGlU,6752
|
|
19
|
+
deezer/utils.py,sha256=Z4QA5Ud5KPiGGv5buTdUidixmkEF9UhwCoYZiGXE-cE,583
|
|
20
|
+
deezer_python-6.0.0.dist-info/LICENSE.txt,sha256=lGqKEubFaPBoiJVRoHOxg1LYlte1e5kLoq6zWUSRQzQ,1054
|
|
21
|
+
deezer_python-6.0.0.dist-info/METADATA,sha256=EIaKci6RJMjIl4tG0-5vEvMxdWTB6wV626XZPM3Ao5o,14597
|
|
22
|
+
deezer_python-6.0.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
23
|
+
deezer_python-6.0.0.dist-info/RECORD,,
|
|
File without changes
|