2727from urllib .parse import urljoin
2828
2929from tidalapi .exceptions import ObjectNotFound
30- from tidalapi .types import JsonObj
30+ from tidalapi .types import JsonObj , AlbumOrder , ItemOrder , OrderDirection , PlaylistOrder , ArtistOrder , MixOrder , VideoOrder
3131
3232if TYPE_CHECKING :
3333 from tidalapi .album import Album
@@ -448,12 +448,27 @@ def remove_folders_playlists(self, trns: [str], type: str = "folder") -> bool:
448448 params = params ,
449449 ).ok
450450
451- def artists (self , limit : Optional [int ] = None , offset : int = 0 ) -> List ["Artist" ]:
451+ def artists (
452+ self ,
453+ limit : Optional [int ] = None ,
454+ offset : int = 0 ,
455+ order : Optional [ArtistOrder ] = None ,
456+ order_direction : Optional [OrderDirection ] = None ,
457+ ) -> List ["Artist" ]:
452458 """Get the users favorite artists.
453459
460+ :param limit: Optional; The amount of artists you want returned.
461+ :param offset: The index of the first artist you want included.
462+ :param order: Optional; A :class:`ArtistOrder` describing the ordering type when returning the user favorite artists. eg.: "NAME, "DATE"
463+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
454464 :return: A :class:`list` of :class:`~tidalapi.artist.Artist` objects containing the favorite artists.
455465 """
456466 params = {"limit" : limit , "offset" : offset }
467+ if order :
468+ params ["order" ] = order .value
469+ if order_direction :
470+ params ["orderDirection" ] = order_direction .value
471+
457472 return cast (
458473 List ["Artist" ],
459474 self .requests .map_request (
@@ -463,12 +478,27 @@ def artists(self, limit: Optional[int] = None, offset: int = 0) -> List["Artist"
463478 ),
464479 )
465480
466- def albums (self , limit : Optional [int ] = None , offset : int = 0 ) -> List ["Album" ]:
481+ def albums (
482+ self ,
483+ limit : Optional [int ] = None ,
484+ offset : int = 0 ,
485+ order : Optional [AlbumOrder ] = None ,
486+ order_direction : Optional [OrderDirection ] = None ,
487+ ) -> List ["Album" ]:
467488 """Get the users favorite albums.
468489
490+ :param limit: Optional; The amount of albums you want returned.
491+ :param offset: The index of the first album you want included.
492+ :param order: Optional; A :class:`AlbumOrder` describing the ordering type when returning the user favorite albums. eg.: "NAME, "DATE"
493+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
469494 :return: A :class:`list` of :class:`~tidalapi.album.Album` objects containing the favorite albums.
470495 """
471496 params = {"limit" : limit , "offset" : offset }
497+ if order :
498+ params ["order" ] = order .value
499+ if order_direction :
500+ params ["orderDirection" ] = order_direction .value
501+
472502 return cast (
473503 List ["Album" ],
474504 self .requests .map_request (
@@ -477,13 +507,26 @@ def albums(self, limit: Optional[int] = None, offset: int = 0) -> List["Album"]:
477507 )
478508
479509 def playlists (
480- self , limit : Optional [int ] = None , offset : int = 0
510+ self ,
511+ limit : Optional [int ] = None ,
512+ offset : int = 0 ,
513+ order : Optional [PlaylistOrder ] = None ,
514+ order_direction : Optional [OrderDirection ] = None ,
481515 ) -> List ["Playlist" ]:
482516 """Get the users favorite playlists.
483517
518+ :param limit: Optional; The amount of playlists you want returned.
519+ :param offset: The index of the first playlist you want included.
520+ :param order: Optional; A :class:`PlaylistOrder` describing the ordering type when returning the user favorite playlists. eg.: "NAME, "DATE"
521+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
484522 :return: A :class:`list` :class:`~tidalapi.playlist.Playlist` objects containing the favorite playlists.
485523 """
486524 params = {"limit" : limit , "offset" : offset }
525+ if order :
526+ params ["order" ] = order .value
527+ if order_direction :
528+ params ["orderDirection" ] = order_direction .value
529+
487530 return cast (
488531 List ["Playlist" ],
489532 self .requests .map_request (
@@ -497,23 +540,22 @@ def tracks(
497540 self ,
498541 limit : Optional [int ] = None ,
499542 offset : int = 0 ,
500- order : str = "NAME" ,
501- order_direction : str = "ASC" ,
543+ order : Optional [ ItemOrder ] = None ,
544+ order_direction : Optional [ OrderDirection ] = None ,
502545 ) -> List ["Track" ]:
503546 """Get the users favorite tracks.
504547
505548 :param limit: Optional; The amount of items you want returned.
506549 :param offset: The index of the first item you want included.
507- :param order: A :class:`str ` describing the ordering type when returning the user favorite tracks. eg.: "NAME, "DATE"
508- :param order_direction: A :class:`str ` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
550+ :param order: Optional; A :class:`ItemOrder ` describing the ordering type when returning the user favorite tracks. eg.: "NAME, "DATE"
551+ :param order_direction: Optional; A :class:`OrderDirection ` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
509552 :return: A :class:`list` of :class:`~tidalapi.media.Track` objects containing all of the favorite tracks.
510553 """
511- params = {
512- "limit" : limit ,
513- "offset" : offset ,
514- "order" : order ,
515- "orderDirection" : order_direction ,
516- }
554+ params = {"limit" : limit , "offset" : offset }
555+ if order :
556+ params ["order" ] = order .value
557+ if order_direction :
558+ params ["orderDirection" ] = order_direction .value
517559
518560 return cast (
519561 List ["Track" ],
@@ -522,24 +564,57 @@ def tracks(
522564 ),
523565 )
524566
525- def videos (self ) -> List ["Video" ]:
567+ def videos (
568+ self ,
569+ limit : Optional [int ] = None ,
570+ offset : int = 0 ,
571+ order : Optional [VideoOrder ] = None ,
572+ order_direction : Optional [OrderDirection ] = None ,
573+ ) -> List ["Video" ]:
526574 """Get the users favorite videos.
527575
576+ :param limit: Optional; The amount of videos you want returned.
577+ :param offset: The index of the first video you want included.
578+ :param order: Optional; A :class:`VideoOrder` describing the ordering type when returning the user favorite videos. eg.: "NAME, "DATE"
579+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
528580 :return: A :class:`list` of :class:`~tidalapi.media.Video` objects containing all the favorite videos
529581 """
582+ params = {"limit" : limit , "offset" : offset }
583+ if order :
584+ params ["order" ] = order .value
585+ if order_direction :
586+ params ["orderDirection" ] = order_direction .value
587+
530588 return cast (
531589 List ["Video" ],
532- self .requests .get_items (
533- f"{ self .base_url } /videos" , parse = self .session .parse_media
590+ self .requests .map_request (
591+ f"{ self .base_url } /videos" ,
592+ params = params ,
593+ parse = self .session .parse_media ,
534594 ),
535595 )
536596
537- def mixes (self , limit : Optional [int ] = 50 , offset : int = 0 ) -> List ["MixV2" ]:
597+ def mixes (
598+ self ,
599+ limit : Optional [int ] = 50 ,
600+ offset : int = 0 ,
601+ order : Optional [MixOrder ] = None ,
602+ order_direction : Optional [OrderDirection ] = None ,
603+ ) -> List ["MixV2" ]:
538604 """Get the users favorite mixes & radio.
539605
606+ :param limit: Optional; The amount of mixes you want returned.
607+ :param offset: The index of the first mix you want included.
608+ :param order: Optional; A :class:`MixOrder` describing the ordering type when returning the user favorite mixes. eg.: "NAME, "DATE"
609+ :param order_direction: Optional; A :class:`OrderDirection` describing the ordering direction when sorting by `order`. eg.: "ASC", "DESC"
540610 :return: A :class:`list` of :class:`~tidalapi.media.Mix` objects containing the user favourite mixes & radio
541611 """
542612 params = {"limit" : limit , "offset" : offset }
613+ if order :
614+ params ["order" ] = order .value
615+ if order_direction :
616+ params ["orderDirection" ] = order_direction .value
617+
543618 return cast (
544619 List ["MixV2" ],
545620 self .requests .map_request (
0 commit comments