diff --git a/larigira/mpc.py b/larigira/mpc.py index bfb4e4a..d60afaf 100644 --- a/larigira/mpc.py +++ b/larigira/mpc.py @@ -58,6 +58,7 @@ class Player: self.conf = conf self.log = logging.getLogger(self.__class__.__name__) self.min_playlist_length = 10 + self.tmpcleaner = UnusedCleaner(conf) self._continous_audiospec = self.conf['CONTINOUS_AUDIOSPEC'] def _get_mpd(self): @@ -89,6 +90,7 @@ class Player: uris = greenlet.value for uri in uris: assert type(uri) is str, type(uri) + self.tmpcleaner.watch(uri.strip()) mpd_client.add(uri.strip()) picker.link_value(add) picker.start() @@ -109,6 +111,7 @@ class Player: mpd_client.addid(uri, insert_pos) except CommandError: self.log.exception("Cannot insert song {}".format(uri)) + self.tmpcleaner.watch(uri.strip()) class Controller(gevent.Greenlet): @@ -118,7 +121,6 @@ class Controller(gevent.Greenlet): self.conf = conf self.q = Queue() self.player = Player(self.conf) - self.tmpcleaner = UnusedCleaner(conf) if 'DB_URI' in self.conf: self.monitor = Monitor(self.q, self.conf) self.monitor.parent_greenlet = self @@ -147,7 +149,7 @@ class Controller(gevent.Greenlet): 'connect')): gevent.Greenlet.spawn(self.player.check_playlist) try: - self.tmpcleaner.check_playlist() + self.player.tmpcleaner.check_playlist() except: pass elif kind == 'mpc': @@ -160,9 +162,6 @@ class Controller(gevent.Greenlet): except Exception: self.log.exception("Error while adding to queue; " "bad audiogen output?") - else: - for fname in args[0]['uris']: - self.tmpcleaner.watch(fname) elif (kind == 'signal' and args[0] == signal.SIGALRM) or \ kind == 'refresh': # it's a tick! diff --git a/larigira/unused.py b/larigira/unused.py index ccc75ab..dfd27d4 100644 --- a/larigira/unused.py +++ b/larigira/unused.py @@ -27,7 +27,7 @@ class UnusedCleaner: as soon as it leaves the mpc playlist, it is removed ''' if not uri.startswith('file:///'): - raise ValueError('not a file URI') + return # not a file URI fpath = uri[len('file://'):] if not os.path.exists(fpath): self.log.warning('a path that does not exist is being monitored')