From 10b375ccb99a8c4926534eaa652ed75ee2646df8 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Wed, 1 Jul 2015 17:54:25 +0200 Subject: [PATCH] CoverArt: add code to handle loading of local files as cover art --- picard/coverart/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/picard/coverart/__init__.py b/picard/coverart/__init__.py index c62ee7e6b..517f11607 100644 --- a/picard/coverart/__init__.py +++ b/picard/coverart/__init__.py @@ -164,6 +164,26 @@ class CoverArt: self.next_in_queue() return + # local files + try: + if coverartimage.filepath: + data = None + try: + with open(coverartimage.filepath, 'rb') as file: + self._set_metadata(coverartimage, file.read()) + except IOError, (errnum, errmsg): + log.error("Failed to read %r: %s (%d)" % + (coverartimage.from_file, errmsg, errnum)) + except CoverArtImageIOError: + # It doesn't make sense to store/download more images if we can't + # save them in the temporary folder, abort. + return + self.next_in_queue() + return + except AttributeError: + pass + + # on the web self._message( N_("Downloading cover art of type '%(type)s' for %(albumid)s from %(host)s ..."), {