X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fwebserv.py;h=6a127f469f3116b74418fb804aa0499d98e8b2c3;hb=d86ba5f99e61ff81ab750aba226df8b8a78dcae5;hp=f0b5946ff6ec50be3577b9611d6e5a0a793b2e78;hpb=c225e922bbeed1d989d1a74ab0a639aa4972c7f1;p=mpd-sima.git diff --git a/sima/lib/webserv.py b/sima/lib/webserv.py index f0b5946..6a127f4 100644 --- a/sima/lib/webserv.py +++ b/sima/lib/webserv.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2009-2014 Jack Kaliko +# Copyright (c) 2009-2015 Jack Kaliko # # This file is part of sima # @@ -168,7 +168,7 @@ class WebService(Plugin): results.append(res) return results - def ws_similar_artists(self, artist=None): + def ws_similar_artists(self, artist): """ Retrieve similar artists from WebServive. """ @@ -179,9 +179,13 @@ class WebService(Plugin): try: [as_art.append(art) for art in as_artists] except WSNotFound as err: - if artist.mbid: - return self.ws_similar_artists(Artist(name=artist.name)) self.log.warning('{}: {}'.format(self.ws.name, err)) + if artist.mbid: + self.log.debug('Trying without MusicBrainzID') + try: + return self.ws_similar_artists(Artist(name=artist.name)) + except WSNotFound as err: + self.log.debug('{}: {}'.format(self.ws.name, err)) except WSError as err: self.log.warning('{}: {}'.format(self.ws.name, err)) if as_art: @@ -264,10 +268,9 @@ class WebService(Plugin): if not ret: self.log.warning('Got nothing from music library.') return [] - # WARNING: - # * operation on set will not match against aliases - # * composite set w/ mbid set and whitout won't match either queued_artists = MetaContainer([trk.Artist for trk in self.player.queue]) + self.log.trace('Already queued: {}'.format(queued_artists)) + self.log.trace('Candidate: {}'.format(ret)) if ret & queued_artists: self.log.debug('Removing already queued artists: ' '{0}'.format('/'.join(map(str, ret & queued_artists)))) @@ -343,7 +346,6 @@ class WebService(Plugin): self.to_add = list() nbtracks_target = self.plugin_conf.getint('track_to_add') for artist in artists: - artist = Artist(name=artist) if len(self.to_add) == nbtracks_target: return True self.log.info('Looking for a top track for {0}'.format(artist))