@@ -66,6 +66,7 @@ def __init__(self) -> None:
6666 "urlencode" : False ,
6767 "pretend_paths" : False ,
6868 "output" : "m3u" ,
69+ "quiet" : False ,
6970 }
7071 )
7172
@@ -94,6 +95,13 @@ def commands(self) -> list[ui.Subcommand]:
9495 dest = "pretend_paths" ,
9596 help = "in pretend mode, log the playlist item URIs/paths." ,
9697 )
98+ spl_update .parser .add_option (
99+ "-q" ,
100+ "--quiet" ,
101+ action = "store_true" ,
102+ dest = "quiet" ,
103+ help = "show matching playlists count only" ,
104+ )
97105 spl_update .parser .add_option (
98106 "-d" ,
99107 "--playlist-dir" ,
@@ -148,6 +156,7 @@ def commands(self) -> list[ui.Subcommand]:
148156
149157 def update_cmd (self , lib : Library , opts : Any , args : list [str ]) -> None :
150158 self .build_queries ()
159+ quiet = self .config ["quiet" ].get (bool ) or opts .quiet
151160 if args :
152161 args_set = set (args )
153162 for a in list (args_set ):
@@ -173,7 +182,7 @@ def update_cmd(self, lib: Library, opts: Any, args: list[str]) -> None:
173182 self ._matched_playlists = self ._unmatched_playlists
174183
175184 self .__apply_opts_to_config (opts )
176- self .update_playlists (lib , opts .pretend )
185+ self .update_playlists (lib , opts .pretend , quiet )
177186
178187 def __apply_opts_to_config (self , opts : Any ) -> None :
179188 for k , v in opts .__dict__ .items ():
@@ -262,13 +271,15 @@ def db_change(self, lib: Library, model: Item | Album) -> None:
262271
263272 self ._unmatched_playlists -= self ._matched_playlists
264273
265- def update_playlists (self , lib : Library , pretend : bool = False ) -> None :
266- if pretend :
274+ def update_playlists (
275+ self , lib : Library , pretend : bool = False , quiet : bool = False
276+ ) -> None :
277+ if pretend and not quiet :
267278 self ._log .info (
268279 "Showing query results for {} smart playlists..." ,
269280 len (self ._matched_playlists ),
270281 )
271- else :
282+ elif not pretend :
272283 self ._log .info (
273284 "Updating {} smart playlists..." , len (self ._matched_playlists )
274285 )
@@ -287,10 +298,11 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
287298 m3us : dict [str , list [PlaylistItem ]] = {}
288299
289300 for playlist in self ._matched_playlists :
301+ pretend_count = 0
290302 name , (query , q_sort ), (album_query , a_q_sort ) = playlist
291- if pretend :
303+ if pretend and not quiet :
292304 self ._log .info ("Results for playlist {}:" , name )
293- else :
305+ elif not quiet :
294306 self ._log .info ("Creating playlist {}" , name )
295307 items = []
296308
@@ -344,10 +356,12 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
344356
345357 if item_uri not in m3us [m3u_name ]:
346358 m3us [m3u_name ].append (PlaylistItem (item , item_uri ))
347- if pretend and self .config ["pretend_paths" ]:
359+ if pretend and self .config ["pretend_paths" ] and not quiet :
348360 print (displayable_path (item_uri ))
349- elif pretend :
361+ elif pretend and not quiet :
350362 print (item )
363+ pretend_count += 1
364+ self ._log .info ("{}: {} items matched." , name , pretend_count )
351365
352366 if not pretend :
353367 # Write all of the accumulated track lists to files.
@@ -385,11 +399,15 @@ def update_playlists(self, lib: Library, pretend: bool = False) -> None:
385399 # Send an event when playlists were updated.
386400 send_event ("smartplaylist_update" ) # type: ignore
387401
388- if pretend :
402+ if pretend and not quiet :
389403 self ._log .info (
390404 "Displayed results for {} playlists" ,
391405 len (self ._matched_playlists ),
392406 )
407+ elif pretend :
408+ self ._log .info (
409+ "{} playlists would be updated" , len (self ._matched_playlists )
410+ )
393411 else :
394412 self ._log .info ("{} playlists updated" , len (self ._matched_playlists ))
395413
0 commit comments