37
37
PlaylistOrder ,
38
38
VideoOrder ,
39
39
)
40
+ from tidalapi .workers import get_items
40
41
41
42
if TYPE_CHECKING :
42
43
from tidalapi .album import Album
@@ -159,36 +160,6 @@ def playlists(self) -> List[Union["Playlist", "UserPlaylist"]]:
159
160
),
160
161
)
161
162
162
- def playlist_folders (
163
- self , offset : int = 0 , limit : int = 50 , parent_folder_id : str = "root"
164
- ) -> List ["Folder" ]:
165
- """Get a list of folders created by the user.
166
-
167
- :param offset: The amount of items you want returned.
168
- :param limit: The index of the first item you want included.
169
- :param parent_folder_id: Parent folder ID. Default: 'root' playlist folder
170
- :return: Returns a list of :class:`~tidalapi.playlist.Folder` objects containing the Folders.
171
- """
172
- params = {
173
- "folderId" : parent_folder_id ,
174
- "offset" : offset ,
175
- "limit" : limit ,
176
- "order" : "NAME" ,
177
- "includeOnly" : "FOLDER" ,
178
- }
179
- endpoint = "my-collection/playlists/folders"
180
- return cast (
181
- List ["Folder" ],
182
- self .session .request .map_request (
183
- url = urljoin (
184
- self .session .config .api_v2_location ,
185
- endpoint ,
186
- ),
187
- params = params ,
188
- parse = self .session .parse_folder ,
189
- ),
190
- )
191
-
192
163
def public_playlists (
193
164
self , offset : int = 0 , limit : int = 50
194
165
) -> List [Union ["Playlist" , "UserPlaylist" ]]:
@@ -573,6 +544,19 @@ def remove_folders_playlists(
573
544
)
574
545
return response .ok
575
546
547
+ def artists_paginated (
548
+ self ,
549
+ order : Optional [ArtistOrder ] = None ,
550
+ order_direction : Optional [OrderDirection ] = None ,
551
+ ) -> List ["Artist" ]:
552
+ """Get the users favorite artists, using pagination.
553
+
554
+ :param order: Optional; A :class:`ArtistOrder` describing the ordering type when returning the user favorite artists. eg.: "NAME, "DATE"
555
+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
556
+ :return: A :class:`list` :class:`~tidalapi.artist.Artist` objects containing the favorite artists.
557
+ """
558
+ return get_items (self .session .user .favorites .artists , order , order_direction )
559
+
576
560
def artists (
577
561
self ,
578
562
limit : Optional [int ] = None ,
@@ -603,6 +587,19 @@ def artists(
603
587
),
604
588
)
605
589
590
+ def albums_paginated (
591
+ self ,
592
+ order : Optional [AlbumOrder ] = None ,
593
+ order_direction : Optional [OrderDirection ] = None ,
594
+ ) -> List ["Album" ]:
595
+ """Get the users favorite albums, using pagination.
596
+
597
+ :param order: Optional; A :class:`AlbumOrder` describing the ordering type when returning the user favorite albums. eg.: "NAME, "DATE"
598
+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
599
+ :return: A :class:`list` :class:`~tidalapi.album.Album` objects containing the favorite albums.
600
+ """
601
+ return get_items (self .session .user .favorites .albums , order , order_direction )
602
+
606
603
def albums (
607
604
self ,
608
605
limit : Optional [int ] = None ,
@@ -631,17 +628,32 @@ def albums(
631
628
),
632
629
)
633
630
631
+ def playlists_paginated (
632
+ self ,
633
+ order : Optional [PlaylistOrder ] = None ,
634
+ order_direction : Optional [OrderDirection ] = None ,
635
+ ) -> List ["Playlist" ]:
636
+ """Get the users favorite playlists relative to the root folder, using
637
+ pagination.
638
+
639
+ :param order: Optional; A :class:`PlaylistOrder` describing the ordering type when returning the user favorite playlists. eg.: "NAME, "DATE"
640
+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
641
+ :return: A :class:`list` :class:`~tidalapi.playlist.Playlist` objects containing the favorite playlists.
642
+ """
643
+ return get_items (self .session .user .favorites .playlists , order , order_direction )
644
+
634
645
def playlists (
635
646
self ,
636
647
limit : Optional [int ] = 50 ,
637
648
offset : int = 0 ,
638
649
order : Optional [PlaylistOrder ] = None ,
639
650
order_direction : Optional [OrderDirection ] = None ,
640
651
) -> List ["Playlist" ]:
641
- """Get the users favorite playlists (v2 endpoint)
652
+ """Get the users favorite playlists (v2 endpoint), relative to the root folder
653
+ This function is limited to 50 by TIDAL, requiring pagination.
642
654
643
- :param limit: Optional; The amount of playlists you want returned.
644
- :param offset: The index of the first playlist you want included.
655
+ :param limit: Optional; The number of playlists you want returned (Note: Cannot exceed 50)
656
+ :param offset: The index of the first playlist to fetch
645
657
:param order: Optional; A :class:`PlaylistOrder` describing the ordering type when returning the user favorite playlists. eg.: "NAME, "DATE"
646
658
:param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
647
659
:return: A :class:`list` :class:`~tidalapi.playlist.Playlist` objects containing the favorite playlists.
@@ -650,14 +662,14 @@ def playlists(
650
662
"folderId" : "root" ,
651
663
"offset" : offset ,
652
664
"limit" : limit ,
653
- "includeOnly" : "" ,
665
+ "includeOnly" : "PLAYLIST" , # Include only PLAYLIST types, FOLDER will be ignored
654
666
}
655
667
if order :
656
668
params ["order" ] = order .value
657
669
if order_direction :
658
670
params ["orderDirection" ] = order_direction .value
659
671
660
- endpoint = "my-collection/playlists/folders "
672
+ endpoint = "my-collection/playlists"
661
673
return cast (
662
674
List ["Playlist" ],
663
675
self .session .request .map_request (
@@ -670,6 +682,62 @@ def playlists(
670
682
),
671
683
)
672
684
685
+ def playlist_folders (
686
+ self ,
687
+ limit : Optional [int ] = 50 ,
688
+ offset : int = 0 ,
689
+ order : Optional [PlaylistOrder ] = None ,
690
+ order_direction : Optional [OrderDirection ] = None ,
691
+ parent_folder_id : str = "root" ,
692
+ ) -> List ["Folder" ]:
693
+ """Get a list of folders created by the user.
694
+
695
+ :param limit: Optional; The number of playlists you want returned (Note: Cannot exceed 50)
696
+ :param offset: The index of the first playlist folder to fetch
697
+ :param order: Optional; A :class:`PlaylistOrder` describing the ordering type when returning the user favorite playlists. eg.: "NAME, "DATE"
698
+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
699
+ :param parent_folder_id: Parent folder ID. Default: 'root' playlist folder
700
+ :return: Returns a list of :class:`~tidalapi.playlist.Folder` objects containing the Folders.
701
+ """
702
+ params = {
703
+ "folderId" : parent_folder_id ,
704
+ "offset" : offset ,
705
+ "limit" : limit ,
706
+ "order" : "NAME" ,
707
+ "includeOnly" : "FOLDER" ,
708
+ }
709
+ if order :
710
+ params ["order" ] = order .value
711
+ if order_direction :
712
+ params ["orderDirection" ] = order_direction .value
713
+
714
+ endpoint = "my-collection/playlists/folders"
715
+ return cast (
716
+ List ["Folder" ],
717
+ self .session .request .map_request (
718
+ url = urljoin (
719
+ self .session .config .api_v2_location ,
720
+ endpoint ,
721
+ ),
722
+ params = params ,
723
+ parse = self .session .parse_folder ,
724
+ ),
725
+ )
726
+
727
+ def tracks_paginated (
728
+ self ,
729
+ order : Optional [ItemOrder ] = None ,
730
+ order_direction : Optional [OrderDirection ] = None ,
731
+ ) -> List ["Playlist" ]:
732
+ """Get the users favorite playlists relative to the root folder, using
733
+ pagination.
734
+
735
+ :param order: Optional; A :class:`ItemOrder` describing the ordering type when returning the user favorite tracks. eg.: "NAME, "DATE"
736
+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
737
+ :return: A :class:`list` :class:`~tidalapi.playlist.Playlist` objects containing the favorite tracks.
738
+ """
739
+ return get_items (self .session .user .favorites .tracks , order , order_direction )
740
+
673
741
def tracks (
674
742
self ,
675
743
limit : Optional [int ] = None ,
0 commit comments