mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 20:42:37 +01:00
Introduce force option in acousticbrainz
This commit is contained in:
parent
f93ee3accc
commit
bbaad2f17d
1 changed files with 15 additions and 7 deletions
|
|
@ -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'always fetch acousticbrainz data',
|
||||
)
|
||||
|
||||
cmd.func = func
|
||||
return [cmd]
|
||||
|
|
@ -151,15 +158,16 @@ 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:
|
||||
|
||||
mood_str = item.get('mood_acoustic', u'')
|
||||
if len(mood_str) != 0:
|
||||
self._log.info(u'Already set acousticbrainz tag for {} ', item)
|
||||
continue
|
||||
if not force:
|
||||
mood_str = item.get('mood_acoustic', u'')
|
||||
if len(mood_str) != 0:
|
||||
self._log.info(u'Already set acousticbrainz tag for {} ', item)
|
||||
continue
|
||||
|
||||
if not item.mb_trackid:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue