Skip to content

Commit

Permalink
Add documentation for the play queue
Browse files Browse the repository at this point in the history
  • Loading branch information
kutu-dev committed Aug 12, 2023
1 parent bfd6cef commit 9705e35
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/knuckles/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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},
Expand Down
10 changes: 9 additions & 1 deletion src/knuckles/models/play_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9705e35

Please sign in to comment.