aboutsummaryrefslogtreecommitdiff
path: root/pyfunkwhale/funkwhale.py
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2020-04-11 20:24:16 +0200
committerneodarz <neodarz@neodarz.net>2020-04-11 20:24:16 +0200
commit74dd9d0fb2534eb290fe6c8e7638480d54e91087 (patch)
tree4bfce3af8f5cb164e97c62c2f61bef96cea1426b /pyfunkwhale/funkwhale.py
parent7591de1343524944f2fe1282c159e663016a1e52 (diff)
downloadpyfunkwhale-74dd9d0fb2534eb290fe6c8e7638480d54e91087.tar.xz
pyfunkwhale-74dd9d0fb2534eb290fe6c8e7638480d54e91087.zip
Add albums endpoints
Diffstat (limited to 'pyfunkwhale/funkwhale.py')
-rw-r--r--pyfunkwhale/funkwhale.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/pyfunkwhale/funkwhale.py b/pyfunkwhale/funkwhale.py
index fc1b4d6..0c92e72 100644
--- a/pyfunkwhale/funkwhale.py
+++ b/pyfunkwhale/funkwhale.py
@@ -67,3 +67,45 @@ class Funkwhale(object):
return self.client.call(
f'/artists/{_id}/libraries/', 'get', params).json()
+
+ def albums(self, q: str = None, artist: int = None, ordering: str = None,
+ playable: bool = None, page: int = None,
+ page_size: int = None) -> dict:
+ """
+ List albums
+ """
+
+ arguments = locals()
+
+ ordering_field = ['creation_date', 'release_date', 'title']
+ if ordering is not None and ordering not in ordering_field:
+ raise ValueError("The ordering field {} is not in the ordering"
+ "fields accepted".format(ordering))
+
+ params = self._build_params(arguments)
+
+ return self.client.call('/albums/', 'get', params).json()
+
+ def album(self, _id: int, refresh: bool = False):
+ """
+ Retrieve a single album
+ """
+
+ arguments = locals()
+
+ params = self._build_params(arguments)
+
+ return self.client.call(f'/albums/{_id}', 'get', params).json()
+
+ def album_libraries(self, _id: int, page: int = None,
+ page_size: int = None):
+ """
+ List available user libraries containing work from this album
+ """
+
+ arguments = locals()
+
+ params = self._build_params(arguments)
+
+ return self.client.call(
+ f'/albums/{_id}/libraries/', 'get', params).json()