]> kaliko git repositories - mpd-sima.git/blob - sima/lib/plugin.py
Move fuzzy_find method in the player.
[mpd-sima.git] / sima / lib / plugin.py
1 # -*- coding: utf-8 -*-
2
3 class Plugin():
4     """
5     First non-empty line of the docstring is used as description
6     Rest of the docstring at your convenience.
7
8     The plugin Name MUST be the same as the module (file name), case
9     insensitive: for instance plugin.py → Plugin
10     It eases plugins discovery and simplifies the code to handle them,
11     IMHO, it's a fair trade-off.
12     """
13
14     @classmethod
15     def info(cls):
16         """self documenting class method
17         """
18         doc = 'Undocumented plugin! Fill "{}" docstring'.format(cls.__name__)
19         if cls.__doc__:
20             doc = cls.__doc__.strip(' \n').splitlines()[0]
21         return {'name': cls.__name__,
22                 'doc': doc,
23                 }
24
25     def __init__(self, daemon):
26         self.log = daemon.log
27         self.__daemon = daemon
28         self.player = daemon.player
29         self.plugin_conf = None
30         self.__get_config()
31
32     def __str__(self):
33         return self.__class__.__name__
34
35     def __get_config(self):
36         """Get plugin's specific configuration from global applications's config
37         """
38         conf = self.__daemon.config
39         for sec in conf.sections():
40             if sec.lower() == self.__class__.__name__.lower():
41                 self.plugin_conf = dict(conf.items(sec))
42         #if self.plugin_conf:
43         #    self.log.debug('Got config for {0}: {1}'.format(self,
44         #                                                    self.plugin_conf))
45
46     def callback_player(self):
47         """
48         Called on player changes, stopped, paused, skipped
49         """
50         pass
51
52     def callback_player_database(self):
53         """
54         Called on player music library changes
55         """
56         pass
57
58     def callback_playlist(self):
59         """
60         Called on playlist changes
61
62         Not returning data
63         """
64         pass
65
66     def callback_next_song(self):
67         """Not returning data,
68         Could be use to scrobble, maintain an history…
69         """
70         pass
71
72     def callback_need_track(self):
73         """Returns a list of Track objects to add
74         """
75         pass
76
77     def callback_need_track_fb(self):
78         """Called when callback_next_song failled to find tracks to queue
79         Returns a list of Track objects to add
80         """
81         pass
82
83     def shutdown(self):
84         pass
85
86
87 # VIM MODLINE
88 # vim: ai ts=4 sw=4 sts=4 expandtab