Skip to content

Commit 4c97ded

Browse files
Merge pull request #2 from DerKO9/main
adds get_user_profile()
2 parents c04d016 + 08da622 commit 4c97ded

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

librespot/core.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,34 @@ def get_playlist(self, playlist: PlaylistId) -> Playlist4External.SelectedListCo
285285
proto.ParseFromString(body)
286286
return proto
287287

288+
def get_user_profile(self, username: str, playlist_limit: int = None, artist_limit: int = None) -> dict[str, typing.Any]:
289+
"""
290+
291+
:param user: str:
292+
:param playlist_limit: int: (Default value = None)
293+
:param artist_limit: int: (Default value = None)
294+
295+
"""
296+
297+
suffix = "/user-profile-view/v3/profile/{}".format(username)
298+
if playlist_limit is not None or artist_limit is not None:
299+
suffix += "?"
300+
if playlist_limit is not None:
301+
suffix += "playlist_limit={}".format(playlist_limit)
302+
if artist_limit is not None:
303+
suffix += "&"
304+
if artist_limit is not None:
305+
suffix += "artist_limit={}".format(artist_limit)
306+
307+
response = self.send("GET", suffix, None, None)
308+
ApiClient.StatusCodeException.check_status(response)
309+
310+
body = response.content
311+
if body is None:
312+
raise ConnectionError("User Profile request for {} failed: No response body".format(username))
313+
314+
return response.json()
315+
288316
def set_client_token(self, client_token):
289317
"""
290318

0 commit comments

Comments
 (0)