2929from beets .plugins import send as send_event
3030from beets .util import (
3131 bytestring_path ,
32- displayable_path ,
3332 mkdirall ,
3433 normpath ,
3534 path_as_posix ,
@@ -64,7 +63,7 @@ def __init__(self) -> None:
6463 "forward_slash" : False ,
6564 "prefix" : "" ,
6665 "urlencode" : False ,
67- "pretend_paths " : False ,
66+ "format " : "$artist - $title" ,
6867 "output" : "m3u" ,
6968 }
7069 )
@@ -88,12 +87,7 @@ def commands(self) -> list[ui.Subcommand]:
8887 action = "store_true" ,
8988 help = "display query results but don't write playlist files." ,
9089 )
91- spl_update .parser .add_option (
92- "--pretend-paths" ,
93- action = "store_true" ,
94- dest = "pretend_paths" ,
95- help = "in pretend mode, log the playlist item URIs/paths." ,
96- )
90+ spl_update .parser .add_format_option (target = "item" )
9791 spl_update .parser .add_option (
9892 "-d" ,
9993 "--playlist-dir" ,
@@ -263,15 +257,10 @@ def db_change(self, lib: Library, model: Item | Album) -> None:
263257 self ._unmatched_playlists -= self ._matched_playlists
264258
265259 def update_playlists (self , lib : Library , pretend : bool = False ) -> None :
266- if pretend :
267- self ._log .info (
268- "Showing query results for {} smart playlists..." ,
269- len (self ._matched_playlists ),
270- )
271- else :
272- self ._log .info (
273- "Updating {} smart playlists..." , len (self ._matched_playlists )
274- )
260+ self ._log .info (
261+ "Updating {} smart playlists..." ,
262+ len (self ._matched_playlists ),
263+ )
275264
276265 playlist_dir = bytestring_path (
277266 self .config ["playlist_dir" ].as_filename ()
@@ -289,11 +278,8 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
289278 m3u_uris_by_name : dict [str , set [Any ]] = {}
290279
291280 for playlist in self ._matched_playlists :
281+ matched_count = 0
292282 name , (query , q_sort ), (album_query , a_q_sort ) = playlist
293- if pretend :
294- self ._log .info ("Results for playlist {}:" , name )
295- else :
296- self ._log .info ("Creating playlist {}" , name )
297283 items = []
298284
299285 # Handle tuple/list of queries (preserves order)
@@ -323,6 +309,7 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
323309
324310 # As we allow tags in the m3u names, we'll need to iterate through
325311 # the items and generate the correct m3u file names.
312+ matched_items : list [tuple [Any , Any ]] = []
326313 for item in items :
327314 m3u_name = item .evaluate_template (name , True )
328315 m3u_name = sanitize_path (m3u_name , lib .replacements )
@@ -348,10 +335,16 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
348335 if item_uri not in m3u_uris_by_name [m3u_name ]:
349336 m3u_uris_by_name [m3u_name ].add (item_uri )
350337 m3us [m3u_name ].append (PlaylistItem (item , item_uri ))
351- if pretend and self .config ["pretend_paths" ]:
352- print (displayable_path (item_uri ))
353- elif pretend :
354- print (item )
338+ matched_items .append ((item , item_uri ))
339+ matched_count += 1
340+
341+ self ._log .info (
342+ "Creating playlist {}: {} tracks." , name , matched_count
343+ )
344+ for item , item_uri in matched_items :
345+ self ._log .debug (
346+ item .evaluate_template (self .config ["format" ].as_str ())
347+ )
355348
356349 if not pretend :
357350 # Write all of the accumulated track lists to files.
@@ -391,7 +384,7 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
391384
392385 if pretend :
393386 self ._log .info (
394- "Displayed results for {} playlists" ,
387+ "{} playlists would be updated " ,
395388 len (self ._matched_playlists ),
396389 )
397390 else :
0 commit comments