From: kaliko Date: Fri, 7 Feb 2014 21:59:16 +0000 (+0100) Subject: Fetch as much as possible from echonest X-Git-Tag: mpd-sima/0.12.0pr3~3 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=deb847c3dbc3bec518f4edd414039098c8d04f3e;p=mpd-sima.git Fetch as much as possible from echonest --- diff --git a/sima/lib/simaecho.py b/sima/lib/simaecho.py index 3c7528f..310bff1 100644 --- a/sima/lib/simaecho.py +++ b/sima/lib/simaecho.py @@ -141,7 +141,7 @@ class SimaEch(): Cache(self.current_element)}) def _controls_answer(self): - """Controls last.fm answer. + """Controls answer. """ status = self.current_element.get('response').get('status') code = status.get('code') @@ -164,7 +164,7 @@ class SimaEch(): else: payload.update(name=artist.name) payload.update(bucket='id:musicbrainz') - payload.update(results=30) + payload.update(results=100) return payload def get_similar(self, artist=None): diff --git a/sima/plugins/internal/echonest.py b/sima/plugins/internal/echonest.py index 9631d70..bcccff6 100644 --- a/sima/plugins/internal/echonest.py +++ b/sima/plugins/internal/echonest.py @@ -175,7 +175,10 @@ class EchoNest(Plugin): as_artists = simaech.get_similar(artist=current) self.log.debug('Requesting EchoNest for "{0}"'.format(current)) try: - [as_art.append(str(a)) for a in as_artists] + for art in as_artists: + if len(as_art) > self.plugin_conf.getint('artists'): + break + as_art.append(str(art)) except EchoNotFound as err: self.log.warning(err) except EchoError as err: @@ -313,7 +316,7 @@ class EchoNest(Plugin): 'history getting too large?') return None for track in self.to_add: - self.log.info('last.fm candidate: {0!s}'.format(track)) + self.log.info('echonest candidates: {0!s}'.format(track)) def _album(self): """Get albums for album queue mode diff --git a/sima/utils/config.py b/sima/utils/config.py index 2670a78..42c0103 100644 --- a/sima/utils/config.py +++ b/sima/utils/config.py @@ -62,6 +62,7 @@ DEFAULT_CONF = { }, 'echonest': { 'queue_mode': "track", #TODO control values + 'artists': "80", 'single_album': "false", 'track_to_add': "1", 'album_to_add': "1",