From 08da622d44a71a66827ad40f248e9c137e4fffda Mon Sep 17 00:00:00 2001 From: Derko Date: Thu, 16 Apr 2026 15:30:27 -0600 Subject: [PATCH] adds get_user_profile() --- librespot/core.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/librespot/core.py b/librespot/core.py index 6ec5c70..e630c13 100644 --- a/librespot/core.py +++ b/librespot/core.py @@ -285,6 +285,34 @@ def get_playlist(self, playlist: PlaylistId) -> Playlist4External.SelectedListCo proto.ParseFromString(body) return proto + def get_user_profile(self, username: str, playlist_limit: int = None, artist_limit: int = None) -> dict[str, typing.Any]: + """ + + :param user: str: + :param playlist_limit: int: (Default value = None) + :param artist_limit: int: (Default value = None) + + """ + + suffix = "/user-profile-view/v3/profile/{}".format(username) + if playlist_limit is not None or artist_limit is not None: + suffix += "?" + if playlist_limit is not None: + suffix += "playlist_limit={}".format(playlist_limit) + if artist_limit is not None: + suffix += "&" + if artist_limit is not None: + suffix += "artist_limit={}".format(artist_limit) + + response = self.send("GET", suffix, None, None) + ApiClient.StatusCodeException.check_status(response) + + body = response.content + if body is None: + raise ConnectionError("User Profile request for {} failed: No response body".format(username)) + + return response.json() + def set_client_token(self, client_token): """