X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fplugins%2Finternal%2Fgenre.py;fp=sima%2Fplugins%2Finternal%2Fgenre.py;h=43aabf7b58dfca48aa6544b49776c768c18cb146;hb=5cbf72d42c713c5a719fa407e6969f0a84fdfe21;hp=808d96db07c04ba3e99eacf4eecd3fc025c2f388;hpb=c23e4560ba184403e94d41cbf0816ed9847406fc;p=mpd-sima.git diff --git a/sima/plugins/internal/genre.py b/sima/plugins/internal/genre.py index 808d96d..43aabf7 100644 --- a/sima/plugins/internal/genre.py +++ b/sima/plugins/internal/genre.py @@ -63,15 +63,14 @@ class Genre(AdvancedPlugin): raise PluginException('MPD >= 0.21 required') def fetch_genres(self): - pldepth = 4 - nbgenres = 2 - current_titles = self.player.playlist[-pldepth:] - genres = [] - for track in current_titles: - if not track.genres: - self.log.debug('No genre found in %s', track) - continue - genres.extend(track.genres) + """Fetches ,at most, nb-depth genre from history, + and returns the nbgenres most present""" + depth = 10 # nb of genre to fetch from history for analysis + nbgenres = 2 # nb of genre to return + genres = [g[0] for g in self.sdb.fetch_genres_history(limit=depth)] + if not genres: + self.log.debug('No genre found in current track history') + return [] genres_analysis = Counter(genres) if genres_analysis.most_common(): self.log.debug('Most common genres: %s', genres_analysis.most_common())