4242 ArtistShort ,
4343 Collection ,
4444 PlayerControl ,
45+ PlaylistShort ,
4546 ServerState ,
4647 TrackShort ,
4748)
@@ -172,8 +173,16 @@ def print_collection_table(collection: Collection, title="Collection"):
172173 sorted_collection .extend (albums_without_release_date )
173174 collection = sorted_collection
174175
176+ if isinstance (sample , PlaylistShort ):
177+ table .add_column ("Title" , style = theme .title_color .as_hex ())
178+ table .add_column ("Public" , style = "italic" )
179+ table .add_column ("# tracks" , style = "bold" )
180+ table .add_column ("User" , style = theme .secondary_color .as_hex ())
181+
175182 for item in collection :
176- table .add_row (* map (str , item .model_dump (exclude_none = True ).values ()))
183+ table .add_row (
184+ * map (str , item .model_dump (exclude_none = True , exclude = {"tracks" }).values ())
185+ )
177186
178187 console .print (table )
179188
@@ -259,6 +268,9 @@ def search(
259268 track : Annotated [
260269 str , typer .Option ("--track" , "-t" , help = "Search by track title." )
261270 ] = "" ,
271+ playlist : Annotated [
272+ str , typer .Option ("--playlist" , "-p" , help = "Search by playlist name." )
273+ ] = "" ,
262274 strict : Annotated [
263275 bool , typer .Option ("--strict" , "-s" , help = "Only consider strict matches." )
264276 ] = False ,
@@ -285,7 +297,7 @@ def search(
285297 if not quiet :
286298 console .print ("🔍 start searching…" )
287299 try :
288- results = deezer .search (artist , album , track , strict , release )
300+ results = deezer .search (artist , album , track , playlist , strict , release )
289301 except ValueError as err :
290302 raise typer .Exit (code = ExitCodes .INVALID_ARGUMENTS ) from err
291303
@@ -391,6 +403,37 @@ def album(
391403 print_collection_table (collection , title = "Album tracks" )
392404
393405
406+ @cli .command ()
407+ def playlist (
408+ playlist_id : str ,
409+ quiet : Annotated [bool , typer .Option ("--quiet" , "-q" , help = "Quiet output." )] = False ,
410+ ids : Annotated [
411+ bool , typer .Option ("--ids" , "-i" , help = "Show only result IDs." )
412+ ] = False ,
413+ ):
414+ """Get playlist tracks."""
415+ if ids :
416+ quiet = True
417+
418+ if playlist_id == "-" :
419+ logger .debug ("Reading playlist id from stdin…" )
420+ playlist_id = click .get_text_stream ("stdin" ).read ().strip ()
421+ logger .debug (f"{ playlist_id = } " )
422+
423+ deezer = get_deezer_client (quiet = quiet )
424+ playlist = deezer .playlist (int (playlist_id ))
425+
426+ if playlist .tracks is None :
427+ console .print ("This playlist contains no tracks." )
428+ raise typer .Exit (code = ExitCodes .INVALID_ARGUMENTS )
429+
430+ if ids :
431+ print_collection_ids (playlist .tracks )
432+ return
433+
434+ print_collection_table (playlist .tracks , title = f"{ playlist .title } " )
435+
436+
394437@cli .command ()
395438def mix (
396439 artist : list [str ],
0 commit comments