Skip to content

Commit 9ad1be5

Browse files
committed
Fix doxygen. Added playlist folders test
Fix formatting, updated doxygen
1 parent 6338a2b commit 9ad1be5

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

tests/test_user.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ def test_get_user_playlists(session):
6060
assert playlist_ids | favourite_ids == both_ids
6161

6262

63+
def test_get_playlist_folders(session):
64+
folder = session.user.create_folder(title="testfolder")
65+
assert folder
66+
folder_ids = [folder.id for folder in session.user.playlist_folders()]
67+
assert folder.id in folder_ids
68+
folder.remove()
69+
assert folder.id not in folder_ids
70+
71+
6372
def test_get_user_playlist_creator(session):
6473
playlist = session.playlist("944dd087-f65c-4954-a9a3-042a574e86e3")
6574
creator = playlist.creator

tidalapi/user.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ def playlists(self) -> List[Union["Playlist", "UserPlaylist"]]:
155155
def playlist_folders(
156156
self, offset: int = 0, limit: int = 50, parent_folder_id: str = "root"
157157
) -> List["Folder"]:
158-
"""Get the playlists created by the user.
158+
"""Get a list of folders created by the user.
159159
160-
:return: Returns a list of :class:`~tidalapi.playlist.Playlist` objects containing the playlists.
160+
:param offset: The amount of items you want returned.
161+
:param limit: The index of the first item you want included.
162+
:param parent_folder_id: Parent folder ID. Default: 'root' playlist folder
163+
:return: Returns a list of :class:`~tidalapi.playlist.Folder` objects containing the Folders.
161164
"""
162165
params = {
163166
"folderId": parent_folder_id,
@@ -184,6 +187,8 @@ def public_playlists(
184187
) -> List[Union["Playlist", "UserPlaylist"]]:
185188
"""Get the (public) playlists created by the user.
186189
190+
:param offset: The amount of items you want returned.
191+
:param limit: The index of the first item you want included.
187192
:return: List of public playlists.
188193
"""
189194
params = {"limit": limit, "offset": offset}
@@ -204,7 +209,7 @@ def public_playlists(
204209
)
205210

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

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

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

0 commit comments

Comments
 (0)