mirror of
https://github.com/beetbox/beets.git
synced 2025-12-25 01:53:31 +01:00
Smartplaylist: offer "splupdate <playlist names>"
splupdate command of the SmartPlaylistPlugin looks in "args" for matches of playlist names.
This commit is contained in:
parent
f06c33cb71
commit
2d9f665848
1 changed files with 24 additions and 6 deletions
|
|
@ -44,15 +44,33 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
self.register_listener('database_change', self.db_change)
|
||||
|
||||
def commands(self):
|
||||
def update(lib, opts, args):
|
||||
self.build_queries()
|
||||
self._matched_playlists = self._unmatched_playlists
|
||||
self.update_playlists(lib)
|
||||
spl_update = ui.Subcommand('splupdate',
|
||||
help='update the smart playlists')
|
||||
spl_update.func = update
|
||||
help='update the smart playlists. Playlist '
|
||||
'names may be passed as arguments.')
|
||||
spl_update.func = self.update_cmd
|
||||
return [spl_update]
|
||||
|
||||
def update_cmd(self, lib, opts, args):
|
||||
self.build_queries()
|
||||
if args:
|
||||
args = set(ui.decargs(args))
|
||||
for a in list(args):
|
||||
if not a.endswith(".m3u"):
|
||||
args.add("{0}.m3u".format(a))
|
||||
|
||||
playlists = {(name, q, a_q)
|
||||
for name, q, a_q in self._unmatched_playlists
|
||||
if name in args}
|
||||
if not playlists:
|
||||
# raise UserError
|
||||
pass
|
||||
self._matched_playlists = playlists
|
||||
self._unmatched_playlists -= playlists
|
||||
else:
|
||||
self._matched_playlists = self._unmatched_playlists
|
||||
|
||||
self.update_playlists(lib)
|
||||
|
||||
def build_queries(self):
|
||||
"""
|
||||
Instanciate queries for the playlists.
|
||||
|
|
|
|||
Loading…
Reference in a new issue