From 9705e35de9b336bd4357b71ec270c3d8560d3550 Mon Sep 17 00:00:00 2001 From: Kutu Date: Sat, 12 Aug 2023 15:45:25 +0200 Subject: [PATCH] Add documentation for the play queue --- src/knuckles/bookmarks.py | 20 ++++++++++++++++++++ src/knuckles/models/play_queue.py | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/knuckles/bookmarks.py b/src/knuckles/bookmarks.py index 4949a49..cdebde1 100644 --- a/src/knuckles/bookmarks.py +++ b/src/knuckles/bookmarks.py @@ -102,6 +102,12 @@ def delete_bookmark(self, id: str) -> "Subsonic": return self.subsonic def get_play_queue(self) -> PlayQueue: + """Calls the "getPlayQueue" endpoint of the API. + + :return: The play queue of the authenticated user. + :rtype: PlayQueue + """ + response = self.api.request("getPlayQueue")["playQueue"] return PlayQueue(self.subsonic, **response) @@ -112,6 +118,20 @@ def save_play_queue( current_song_id: str | None = None, position: int | None = None, ) -> PlayQueue: + """Calls the "savePlayQueue" endpoint of the API. + + :param song_ids: A list with all the IDs of the songs to add. + :type song_ids: list[str] + :param current_song_id: The ID of the current song in the queue, + defaults to None. + :type current_song_id: str | None, optional + :param position: The position in seconds of the current song, + defaults to None. + :type position: int | None, optional + :return: The new saved play queue. + :rtype: PlayQueue + """ + self.api.request( "savePlayQueue", {"id": song_ids, "current": current_song_id, "position": position}, diff --git a/src/knuckles/models/play_queue.py b/src/knuckles/models/play_queue.py index 7ae6171..9b9601a 100644 --- a/src/knuckles/models/play_queue.py +++ b/src/knuckles/models/play_queue.py @@ -48,7 +48,15 @@ def generate(self) -> "PlayQueue": return get_play_queue def save(self) -> Self: - # TODO This should raise an exception + """Calls the "savePlayQueue" endpoint of the API. + + Saves the play queue using the parameters in the object. + + :return: _description_ + :rtype: Self + """ + + # TODO This should raise an exception? song_ids: list[str] = [song.id for song in self.songs] if self.songs else [] self.__subsonic.bookmarks.save_play_queue(