aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2020-04-12 09:03:11 +0200
committerneodarz <neodarz@neodarz.net>2020-04-12 09:03:11 +0200
commit86de4c99f707992f9b1c6008cdbefc5540523ac2 (patch)
tree1268a4b86ed4f8cb60ce57184b3a7f266544d554
parent92528fe0387dddaf19ba562fe98bf073c8a756c9 (diff)
downloadpyfunkwhale-86de4c99f707992f9b1c6008cdbefc5540523ac2.tar.xz
pyfunkwhale-86de4c99f707992f9b1c6008cdbefc5540523ac2.zip
Add favorites add/delete endpoint
-rw-r--r--README.md6
-rw-r--r--pyfunkwhale/funkwhale.py35
2 files changed, 38 insertions, 3 deletions
diff --git a/README.md b/README.md
index 32433f7..70cc2ba 100644
--- a/README.md
+++ b/README.md
@@ -111,7 +111,7 @@ List of features implemented or planned:
- [ ] Upload a new file in a library
- [ ] Retrieve an upload
- [ ] Delete a an upload
-- [/] favorites
+- [x] favorites
- [x] List favorites
- - [ ] Mark a given track as favorite
- - [ ] Remove a given track from favorites
+ - [x] Mark a given track as favorite
+ - [x] Remove a given track from favorites
diff --git a/pyfunkwhale/funkwhale.py b/pyfunkwhale/funkwhale.py
index 38c388d..7d7bc3c 100644
--- a/pyfunkwhale/funkwhale.py
+++ b/pyfunkwhale/funkwhale.py
@@ -374,3 +374,38 @@ class Funkwhale(object):
params = self._build_params(arguments)
return self.client.call(f'/favorites/tracks/', 'get', params).json()
+
+ def add_favorite_track(self, track: str) -> dict:
+ """
+ Add a track to favorite
+
+ Parameters
+ ----------
+ track : str
+ The track id to add to favorites
+ """
+
+ arguments = locals()
+
+ data = self._build_params(arguments)
+
+ return self.client.call(
+ f'/favorites/tracks', 'post', data=data).json()
+
+ def delete_favorite_track(self, track: str) -> Response:
+ """
+ Remove a track from favorites.
+
+
+ Parameters
+ ----------
+ track : str
+ The track id to remove from favorites
+ """
+
+ arguments = locals()
+
+ data = self._build_params(arguments)
+
+ return self.client.call(
+ f'/favorites/tracks/remove/', 'post', data=data)