Skip to content

Commit

Permalink
Fix doxygen. Added playlist folders test
Browse files Browse the repository at this point in the history
Fix formatting, updated doxygen
  • Loading branch information
tehkillerbee committed Oct 14, 2024
1 parent 6338a2b commit 9ad1be5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
9 changes: 9 additions & 0 deletions tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ def test_get_user_playlists(session):
assert playlist_ids | favourite_ids == both_ids


def test_get_playlist_folders(session):
folder = session.user.create_folder(title="testfolder")
assert folder
folder_ids = [folder.id for folder in session.user.playlist_folders()]
assert folder.id in folder_ids
folder.remove()
assert folder.id not in folder_ids


def test_get_user_playlist_creator(session):
playlist = session.playlist("944dd087-f65c-4954-a9a3-042a574e86e3")
creator = playlist.creator
Expand Down
24 changes: 21 additions & 3 deletions tidalapi/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ def playlists(self) -> List[Union["Playlist", "UserPlaylist"]]:
def playlist_folders(
self, offset: int = 0, limit: int = 50, parent_folder_id: str = "root"
) -> List["Folder"]:
"""Get the playlists created by the user.
"""Get a list of folders created by the user.
:return: Returns a list of :class:`~tidalapi.playlist.Playlist` objects containing the playlists.
:param offset: The amount of items you want returned.
:param limit: The index of the first item you want included.
:param parent_folder_id: Parent folder ID. Default: 'root' playlist folder
:return: Returns a list of :class:`~tidalapi.playlist.Folder` objects containing the Folders.
"""
params = {
"folderId": parent_folder_id,
Expand All @@ -184,6 +187,8 @@ def public_playlists(
) -> List[Union["Playlist", "UserPlaylist"]]:
"""Get the (public) playlists created by the user.
:param offset: The amount of items you want returned.
:param limit: The index of the first item you want included.
:return: List of public playlists.
"""
params = {"limit": limit, "offset": offset}
Expand All @@ -204,7 +209,7 @@ def public_playlists(
)

def playlist_and_favorite_playlists(
self, offset: int = 0, limit: int = 50
self, limit: Optional[int] = None, offset: int = 0
) -> List[Union["Playlist", "UserPlaylist"]]:
"""Get the playlists created by the user, and the playlists favorited by the
user. This function is limited to 50 by TIDAL, requiring pagination.
Expand All @@ -228,6 +233,13 @@ def playlist_and_favorite_playlists(
def create_playlist(
self, title: str, description: str, parent_id: str = "root"
) -> "UserPlaylist":
"""Create a playlist in the specified parent folder.
:param title: Playlist title
:param description: Playlist description
:param parent_id: Parent folder ID. Default: 'root' playlist folder
:return: Returns an object of :class:`~tidalapi.playlist.UserPlaylist` containing the newly created playlist
"""
params = {"name": title, "description": description, "folderId": parent_id}
endpoint = "my-collection/playlists/folders/create-playlist"

Expand All @@ -245,6 +257,12 @@ def create_playlist(
raise ObjectNotFound("Playlist not found after creation")

def create_folder(self, title: str, parent_id: str = "root") -> "Folder":
"""Create folder in the specified parent folder.
:param title: Folder title
:param parent_id: Folder parent ID. Default: 'root' playlist folder
:return: Returns an object of :class:`~tidalapi.playlist.Folder` containing the newly created object
"""
params = {"name": title, "folderId": parent_id}
endpoint = "my-collection/playlists/folders/create-folder"

Expand Down

0 comments on commit 9ad1be5

Please sign in to comment.