mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
Trigger subsonicupdate on db_change and splupdate
- Trigger subsonicupdate on database_change event instead of only at import event. - Send a new event from smartplaylist plugin whenever lists are updated/created and have subsonicupdate plugin listen to it. - Make sure the both events register a new listener that launches the actual subsonic library update at the very end of a beets run (cli_exit) instead of during each change (similar to how mpdupdate plugin does it).
This commit is contained in:
parent
ab3e2a98d1
commit
e9f840580a
2 changed files with 11 additions and 1 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.plugins import send as send_event
|
||||
from beets import ui
|
||||
from beets.util import (mkdirall, normpath, sanitize_path, syspath,
|
||||
bytestring_path, path_as_posix, displayable_path)
|
||||
|
|
@ -232,6 +233,8 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
if self.config['urlencode']:
|
||||
path = bytestring_path(pathname2url(path))
|
||||
f.write(prefix + path + b'\n')
|
||||
# Send an event when playlists were updated.
|
||||
send_event("smartplaylist_update")
|
||||
|
||||
if pretend:
|
||||
self._log.info("Displayed results for {0} playlists",
|
||||
|
|
|
|||
|
|
@ -53,7 +53,14 @@ class SubsonicUpdate(BeetsPlugin):
|
|||
'auth': 'token',
|
||||
})
|
||||
config['subsonic']['pass'].redact = True
|
||||
self.register_listener('import', self.start_scan)
|
||||
self.register_listener('database_change', self.db_change)
|
||||
self.register_listener('smartplaylist_update', self.spl_update)
|
||||
|
||||
def db_change(self, lib, model):
|
||||
self.register_listener('cli_exit', self.start_scan)
|
||||
|
||||
def spl_update(self):
|
||||
self.register_listener('cli_exit', self.start_scan)
|
||||
|
||||
@staticmethod
|
||||
def __create_token():
|
||||
|
|
|
|||
Loading…
Reference in a new issue