diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 91b77c0a4..6fc7ad433 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -824,9 +824,15 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): action='store_true', default=False, help=u're-download art when already present' ) + cmd.parser.add_option( + u'-m', u'--missing', dest='missing', + action='store_true', default=False, + help=u'shows only missing art' + ) def func(lib, opts, args): - self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force) + self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force, + opts.missing) cmd.func = func return [cmd] @@ -866,13 +872,16 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): return out - def batch_fetch_art(self, lib, albums, force): + def batch_fetch_art(self, lib, albums, force, missing): """Fetch album art for each of the albums. This implements the manual fetchart CLI command. """ for album in albums: if album.artpath and not force and os.path.isfile(album.artpath): - message = ui.colorize('text_highlight_minor', u'has album art') + if not missing: + message = ui.colorize('text_highlight_minor', + u'has album art') + self._log.info(u'{0}: {1}', album, message) else: # In ordinary invocations, look for images on the # filesystem. When forcing, however, always go to the Web @@ -885,5 +894,4 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): message = ui.colorize('text_success', u'found album art') else: message = ui.colorize('text_error', u'no art found') - - self._log.info(u'{0}: {1}', album, message) + self._log.info(u'{0}: {1}', album, message) diff --git a/docs/plugins/fetchart.rst b/docs/plugins/fetchart.rst index 97e88c03c..4ca289799 100644 --- a/docs/plugins/fetchart.rst +++ b/docs/plugins/fetchart.rst @@ -106,6 +106,17 @@ be processed; otherwise, the command processes every album in your library. .. _image-resizing: +Display Only Missing Album Art +------------------------------ + +Use the ``fetchart`` command with the ``-m`` switch in order to display only missing +art:: + + $ beet fetchart [-m] [query] + +By default the command will display all results, the ``-m`` or ``--missing`` +switch will only display results for those album arts that still miss. + Image Resizing -------------- diff --git a/test/test_art.py b/test/test_art.py index 6b0e5bbc5..df70dd56a 100644 --- a/test/test_art.py +++ b/test/test_art.py @@ -518,7 +518,8 @@ class ArtImporterTest(UseThePlugin): # message " has album art". self._fetch_art(True) util.remove(self.album.artpath) - self.plugin.batch_fetch_art(self.lib, self.lib.albums(), force=False) + self.plugin.batch_fetch_art(self.lib, self.lib.albums(), force=False, + missing=False) self.assertExists(self.album.artpath)