Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement social followers endpoints #30

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading