Skip to content

Commit d932aa4

Browse files
authored
Merge pull request #2750 from woparry/master
Add tags configuration to acousticbrainz plugin
2 parents 28cb79b + 1f45ea0 commit d932aa4

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

beetsplug/acousticbrainz.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def __init__(self):
110110
self.config.add({
111111
'auto': True,
112112
'force': False,
113+
'tags': []
113114
})
114115

115116
if self.config['auto']:
@@ -164,6 +165,7 @@ def _get_data(self, mbid):
164165
def _fetch_info(self, items, write, force):
165166
"""Fetch additional information from AcousticBrainz for the `item`s.
166167
"""
168+
tags = self.config['tags'].as_str_seq()
167169
for item in items:
168170
# If we're not forcing re-downloading for all tracks, check
169171
# whether the data is already present. We use one
@@ -183,11 +185,18 @@ def _fetch_info(self, items, write, force):
183185
data = self._get_data(item.mb_trackid)
184186
if data:
185187
for attr, val in self._map_data_to_scheme(data, ABSCHEME):
186-
self._log.debug(u'attribute {} of {} set to {}',
187-
attr,
188-
item,
189-
val)
190-
setattr(item, attr, val)
188+
if not tags or attr in tags:
189+
self._log.debug(u'attribute {} of {} set to {}',
190+
attr,
191+
item,
192+
val)
193+
setattr(item, attr, val)
194+
else:
195+
self._log.debug(u'skipping attribute {} of {}'
196+
u' (value {}) due to config',
197+
attr,
198+
item,
199+
val)
191200
item.store()
192201
if write:
193202
item.try_write()

docs/changelog.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ New features:
3131
before touching your files.
3232
Thanks to :user:`konman2`.
3333
:bug:`2708` :bug:`2427`
34-
* :doc:`/plugins/lyrics`: The Genius backend should work again.
35-
Thanks to :user:`lmagno`.
36-
:bug:`2709`
34+
* :doc:`/plugins/acousticbrainz`: The plugin can now be configured to write only
35+
a specific list of tags.
36+
Thanks to :user:`woparry`.
3737

3838
Fixes:
3939

docs/plugins/acousticbrainz.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ Configuration
5454
-------------
5555

5656
To configure the plugin, make a ``acousticbrainz:`` section in your
57-
configuration file. There is one option:
57+
configuration file. There are three options:
5858

5959
- **auto**: Enable AcousticBrainz during ``beet import``.
6060
Default: ``yes``.
6161
- **force**: Download AcousticBrainz data even for tracks that already have
6262
it.
6363
Default: ``no``.
64+
- **tags**: Which tags from the list above to set on your files.
65+
Default: [] (all)

0 commit comments

Comments
 (0)