X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fplugin.py;h=49cd7f155d9c0ee057e0353aef4e27cf4e28f10f;hb=67d87e47012b5d3ceba56bdff06a0fa406f4840b;hp=37ce214aa24be30bffc7ea259e57040eb05d447b;hpb=c806cb3dbeee61c9c4d023f75a862a33d32ef026;p=mpd-sima.git diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index 37ce214..49cd7f1 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013-2015, 2020 kaliko +# Copyright (c) 2013-2015, 2020-2021 kaliko # # This file is part of sima # @@ -82,50 +82,42 @@ class Plugin: 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 """ - pass def callback_player_database(self): """ Called on player music library changes """ - pass def callback_playlist(self): """ Called on playlist changes Not returning data """ - pass def callback_next_song(self): """ 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 """ - pass def callback_need_track_fb(self): """ Called when callback_need_track failled to find tracks to queue Returns a list of Track objects to add """ - pass def shutdown(self): """Called on application shutdown""" - pass class AdvancedPlugin(Plugin): @@ -165,12 +157,12 @@ class AdvancedPlugin(Plugin): :param {Artist} alist: Artist objects list/container """ - queued_artist = MetaContainer([Artist(_.artist) for _ in self.player.queue]) + queued_artist = MetaContainer([Artist(_.artist) for _ in + self.player.queue if _.artist]) not_queued_artist = alist - queued_artist duration = self.main_conf.getint('sima', 'history_duration') hist = [] - for art in self.sdb.get_artists_history(alist, - duration=duration): + for art in self.sdb.get_artists_history(alist, duration=duration): if art not in hist: if art not in queued_artist: hist.insert(0, art) @@ -218,11 +210,12 @@ class AdvancedPlugin(Plugin): album) continue album_to_queue = album + break if not album_to_queue: self.log.info('No album found for "%s"', artist) return None - self.log.info('%s album candidate: %s - %s', self.__class__.__name__, - artist, album_to_queue) + self.log.info('%s plugin chose album: %s - %s', + self.__class__.__name__, artist, album_to_queue) return album_to_queue def filter_track(self, tracks, unplayed=False):