From f2a0c1b2cdc43eb91141a0f2b1f6bcd76096b7bd Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Tue, 6 May 2014 16:44:18 +0200 Subject: [PATCH] Modify how we skip unneeded front images from non-CAA sources Instead of looping and modify the try list, just check in _walk() and continue. Improve debugging messages (no more silent removal in debug mode). --- picard/coverart.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/picard/coverart.py b/picard/coverart.py index 3cbebfaa0..b1e53ea57 100644 --- a/picard/coverart.py +++ b/picard/coverart.py @@ -120,6 +120,7 @@ class CoverArt: self.release = release self.caa_types = map(unicode.lower, config.setting["caa_image_types"]) self.len_caa_types = len(self.caa_types) + self.at_least_one_front_image = False def __repr__(self): return "CoverArt for %r" % (self.album) @@ -226,11 +227,9 @@ class CoverArt: return # If the image already was a front image, there might still be some - # other non-CAA front images in the try_list - remove them. - if coverartimage.is_front_image(): - for item in self.try_list[:]: - if not item.support_types: - self.try_list.remove(item) + # other non-CAA front images in the queue - ignore them. + if not self.at_least_one_front_image: + self.at_least_one_front_image = coverartimage.is_front_image() self._walk() def _caa_json_downloaded(self, data, http, error): @@ -318,6 +317,14 @@ class CoverArt: # We still have some items to try! coverartimage = self.try_list.pop(0) + if not coverartimage.support_types and self.at_least_one_front_image: + # we already have one front image, no need to try other type-less + # sources + log.debug("Skipping cover art %r, one front image is already available", + coverartimage) + self._walk() + return + self.message( N_("Downloading cover art of type '%(type)s' for %(albumid)s from %(host)s ..."), {