Skip to content

Commit

Permalink
Implement social followers endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Weissnix4711 committed Jan 27, 2024
1 parent e9d211b commit 2391450
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions liblistenbrainz/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,34 @@ def delete_listen(self, listen):
)


def follow(self, username):
""" Follow a user
:param username: User to follow
"""
headers = {
'Content-Type': 'application/json',
}
return self._post(
f'/1/user/{username}/follow',
headers=headers
)


def unfollow(self, username):
""" Unfollow a user
:param username: User to unfollow
"""
headers = {
'Content-Type': 'application/json',
}
return self._post(
f'/1/user/{username}/unfollow'
headers=headers
)


def is_token_valid(self, token):
""" Check if the specified ListenBrainz auth token is valid using the ``/1/validate-token`` endpoint.
Expand Down Expand Up @@ -495,3 +523,25 @@ def get_user_feedback(self, username, score, metadata, count=100, offset=0 ):
return None
else:
raise


def get_user_followers(self, username):
""" Get followers for a user
: param username: The user to get followers for
"""
try:
return self._get(f'/1/user/{username}/followers')
except errors.ListenBrainzAPIException:
raise


def get_user_following(self, username):
""" Get following for a user
: param username: The user to get following for
"""
try:
return self._get(f'/1/user/{username}/following')
except errors.ListenBrainzAPIException:
raise

0 comments on commit 2391450

Please sign in to comment.