Merge pull request #2349 from SusannaMaria/#2347

#2347: First hack of ignoring already tagged items
This commit is contained in:
Adrian Sampson 2016-12-28 11:55:21 -05:00
commit 9db79835d6
2 changed files with 26 additions and 4 deletions

View file

@ -107,7 +107,8 @@ class AcousticPlugin(plugins.BeetsPlugin):
def __init__(self):
super(AcousticPlugin, self).__init__()
self.config.add({'auto': True})
self.config.add({'auto': True, 'force': False})
if self.config['auto']:
self.register_listener('import_task_files',
self.import_task_files)
@ -118,7 +119,13 @@ class AcousticPlugin(plugins.BeetsPlugin):
def func(lib, opts, args):
items = lib.items(ui.decargs(args))
self._fetch_info(items, ui.should_write())
self._fetch_info(items, ui.should_write(),
opts.force_refetch or self.config['force'])
cmd.parser.add_option(
u'-f', u'--force', dest='force_refetch',
action='store_true', default=False,
help=u're-download data when already present'
)
cmd.func = func
return [cmd]
@ -151,10 +158,17 @@ class AcousticPlugin(plugins.BeetsPlugin):
return data
def _fetch_info(self, items, write):
def _fetch_info(self, items, write, force):
"""Fetch additional information from AcousticBrainz for the `item`s.
"""
for item in items:
if not force:
mood_str = item.get('mood_acoustic', u'')
if mood_str:
self._log.info(u'Already set acoustic\
brainz tags for {} ', item)
continue
if not item.mb_trackid:
continue

View file

@ -8,7 +8,12 @@ The ``acousticbrainz`` plugin gets acoustic-analysis information from the
Enable the ``acousticbrainz`` plugin in your configuration (see :ref:`using-plugins`) and run it by typing::
$ beet acousticbrainz [QUERY]
$ beet acousticbrainz [-f] [QUERY]
By default, the command will only look for acousticbrainz data when the tracks doesn't
already have it; the ``-f`` or ``--force`` switch makes it fetch acousticbrainz
for the item. If you specify a query, only matching tracks will be processed;
otherwise, the command processes every track in your library.
For all tracks with a MusicBrainz recording ID, the plugin currently sets
these fields:
@ -52,3 +57,6 @@ configuration file. There is one option:
- **auto**: Enable AcousticBrainz during ``beet import``.
Default: ``yes``.
- **force**: By default, beets will not override already fetched acousticbrainz data. To instead fetch acousticbrainz and override data,
set the ``force`` option to ``yes``.
Default: ``no``.