]> kaliko git repositories - mpd-sima.git/blob - sima/plugins/core/history.py
b79105333a54dffe12841a9a19f0dc72a3fbabdd
[mpd-sima.git] / sima / plugins / core / history.py
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2013, 2014 Jack Kaliko <kaliko@azylum.org>
3 #
4 #  This file is part of sima
5 #
6 #  sima is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  sima is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with sima.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 #
20 """Add playing tracks to history
21 """
22
23 # standard library import
24
25 # third parties components
26
27 # local import
28 from ...lib.plugin import Plugin
29
30 class History(Plugin):
31     """
32     History management
33     """
34     def __init__(self, daemon):
35         Plugin.__init__(self, daemon)
36         self.sdb = daemon.sdb
37
38     def shutdown(self):
39         self.log.info('Cleaning database')
40         self.sdb.purge_history()
41         self.sdb.clean_database()
42
43     def callback_next_song(self):
44         current = self.player.current
45         self.log.debug('add history: "{}"'.format(current))
46         self.sdb.add_history(current)
47
48
49 # VIM MODLINE
50 # vim: ai ts=4 sw=4 sts=4 expandtab