Merge pull request #2683 from euri10/master

Added a missing switch to the fetchart command
This commit is contained in:
Adrian Sampson 2017-09-05 14:59:12 -04:00 committed by GitHub
commit cb2cb00959
4 changed files with 29 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'-q', u'--quiet', dest='quiet',
action='store_true', default=False,
help=u'shows only quiet 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.quiet)
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, quiet):
"""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 quiet:
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

@ -9,6 +9,9 @@ New features:
* :doc:`/plugins/lyrics`: The plugin can now produce reStructuredText files
for beautiful, readable books of lyrics. Thanks to :user:`anarcat`.
:bug:`2628`
* :doc:`/plugins/fetchart`: The plugin has now a quiet switch that will only
display missing album arts. Thanks to :user:`euri10`.
:bug:`2683`
Fixes:

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 ``-q`` switch in order to display only missing
art::
$ beet fetchart [-q] [query]
By default the command will display all results, the ``-q`` or ``--quiet``
switch will only display results for album arts that are still missing.
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,
quiet=False)
self.assertExists(self.album.artpath)