X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fplugin.py;h=559e59ffc50a4a6c4510cc5ddc5f10f26ac07f9c;hb=23309f235879380a5ef7db3a51bda4d12e31902e;hp=5f709422410754a5be0a3d0dcfbcd5142bd92f22;hpb=6d8430680bdea646cd17f27e3ec58c5f9ee1d629;p=mpd-sima.git diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index 5f70942..559e59f 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, 2014 Jack Kaliko +# Copyright (c) 2013-2015 Jack Kaliko # # This file is part of sima # @@ -21,13 +21,14 @@ Plugin object to derive from """ + class Plugin: """ First non-empty line of the docstring is used as description Rest of the docstring at your convenience. - The plugin Name MUST be the same as the module (file name), case - insensitive: for instance plugin.py → Plugin + The lowercased plugin Name MUST be the same as the module (file name), + for instance Plugin → plugin.py It eases plugins discovery and simplifies the code to handle them, IMHO, it's a fair trade-off. """ @@ -57,13 +58,28 @@ class Plugin: """Get plugin's specific configuration from global applications's config """ conf = self.__daemon.config - for sec in conf.sections(): + for sec in conf.sections(): # Discovering plugin conf if sec == self.__class__.__name__.lower(): self.plugin_conf = conf[sec] + if 'priority' not in self.plugin_conf: + self.plugin_conf['priority'] = '80' + if not self.plugin_conf: + self.plugin_conf = {'priority': '80'} #if self.plugin_conf: # self.log.debug('Got config for {0}: {1}'.format(self, # self.plugin_conf)) + @property + def priority(self): + return self.plugin_conf.get('priority') + + def start(self): + """ + Called when the daemon().run() is called and + right after the player has connected successfully. + """ + pass + def callback_player(self): """ Called on player changes, stopped, paused, skipped @@ -79,24 +95,26 @@ class Plugin: def callback_playlist(self): """ Called on playlist changes - Not returning data """ pass def callback_next_song(self): - """Not returning data, + """ Could be use to scrobble, maintain an history… + Not returning data, """ pass def callback_need_track(self): - """Returns a list of Track objects to add + """ + Returns a list of Track objects to add """ pass def callback_need_track_fb(self): - """Called when callback_next_song failled to find tracks to queue + """ + Called when callback_need_track failled to find tracks to queue Returns a list of Track objects to add """ pass