Added a missing switch to the fetchart command so that only missing albums

are displayed
This commit is contained in:
euri10 2017-09-05 16:34:26 +02:00
parent 34246a00e7
commit b2fd274e2c
3 changed files with 26 additions and 6 deletions

View file

@ -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)

View file

@ -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
--------------

View file

@ -518,7 +518,8 @@ class ArtImporterTest(UseThePlugin):
# message "<album> 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)