X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fplugins%2Fcore%2Fhistory.py;h=3380870754b84a12c775dd0075b40173e1f0c0c6;hb=c23e4560ba184403e94d41cbf0816ed9847406fc;hp=6c3ad907ce6a5c19ed453f6a42dea50104656426;hpb=38d17f3c7dfcf2909ca1d6c17ec8483b8dd74a37;p=mpd-sima.git diff --git a/sima/plugins/core/history.py b/sima/plugins/core/history.py index 6c3ad90..3380870 100644 --- a/sima/plugins/core/history.py +++ b/sima/plugins/core/history.py @@ -39,15 +39,21 @@ class History(Plugin): def shutdown(self): self.log.info('Cleaning database') self.sdb.purge_history() - self.sdb.clean_database() + + def _h_tip(self): + hist = self.sdb.fetch_history() + if hist: + return hist[0] + return None def callback_player(self): current = self.player.current - last_hist = next(self.sdb.get_history(), None) - if last_hist and last_hist[3] == current.file: - return if not current: - self.log.debug('Cannot add "%s" to history (empty or missing file)', current) + if self.player.state == 'play': + self.log.debug('Cannot add "%s" to history (empty or missing file)', current) + return + last_hist = self._h_tip() + if last_hist and last_hist == current: return self.log.debug('add history: "%s"', current) self.sdb.add_history(current)