X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fplugins%2Finternal%2Fechonest.py;h=4cd2f1d69b41171feaa728dfc7d469431133d6a3;hb=cdb998d12265ec4e1f64c87cff22a8657e2a93ea;hp=bcccff62eda46d4f0b35a04e316b84cb31733437;hpb=deb847c3dbc3bec518f4edd414039098c8d04f3e;p=mpd-sima.git diff --git a/sima/plugins/internal/echonest.py b/sima/plugins/internal/echonest.py index bcccff6..4cd2f1d 100644 --- a/sima/plugins/internal/echonest.py +++ b/sima/plugins/internal/echonest.py @@ -152,8 +152,13 @@ class EchoNest(Plugin): Look in player library for availability of similar artists in similarities """ + dynamic = self.plugin_conf.getint('dynamic') + if dynamic <= 0: + dynamic = 100 + similarity = self.plugin_conf.getint('similarity') results = list() - while len(similarities) > 0: + while (len(results) < dynamic + and len(similarities) > 0): art_pop = similarities.pop() results.extend(self.player.fuzzy_find_artist(art_pop)) return results @@ -175,10 +180,8 @@ class EchoNest(Plugin): as_artists = simaech.get_similar(artist=current) self.log.debug('Requesting EchoNest for "{0}"'.format(current)) try: - for art in as_artists: - if len(as_art) > self.plugin_conf.getint('artists'): - break - as_art.append(str(art)) + # TODO: let's propagate Artist type + [as_art.append(str(art)) for art in as_artists] except EchoNotFound as err: self.log.warning(err) except EchoError as err: @@ -218,13 +221,13 @@ class EchoNest(Plugin): return ret_extra def get_local_similar_artists(self): - """Check against local player for similar artists fetched from last.fm + """Check against local player for similar artists fetched from echonest """ current = self.player.current self.log.info('Looking for artist similar to "{0.artist}"'.format(current)) similar = list(self.lfm_similar_artists()) if not similar: - self.log.info('Got nothing from last.fm!') + self.log.info('Got nothing from echonest!') return [] self.log.info('First five similar artist(s): {}...'.format( ' / '.join([a for a in similar[0:5]]))) @@ -291,7 +294,7 @@ class EchoNest(Plugin): if not album_to_queue: self.log.info('No album found for "%s"' % artist) continue - self.log.info('last.fm album candidate: {0} - {1}'.format( + self.log.info('echonest album candidates: {0} - {1}'.format( artist, album_to_queue)) nb_album_add += 1 self.to_add.extend(self.player.find_album(artist, album_to_queue)) @@ -333,7 +336,11 @@ class EchoNest(Plugin): def callback_need_track(self): self._cleanup_cache() if not self.player.current: - self.log.info('Not currently playing track, cannot queue') + self.log.info('No current track, cannot queue') + return None + if not self.player.current.artist: + self.log.warning('No artist set for the current track') + self.log.debug(repr(self.player.current)) return None self.queue_mode() candidates = self.to_add