mirror of
https://github.com/beetbox/beets.git
synced 2026-03-26 23:33:43 +01:00
fetchart: handle sources config given as plain string
When 'sources' is given as a plain string (e.g. 'sources: filesystem' instead of 'sources: [filesystem]'), confuse's Pairs template iterates over individual characters instead of treating it as a single-item list. This normalizes the string to a list before calling as_pairs(). Fixes #6336 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1943b14565
commit
f33592e9ec
3 changed files with 35 additions and 0 deletions
|
|
@ -1413,6 +1413,13 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
|
|||
if s_cls.available(self._log, self.config)
|
||||
for c in s_cls.VALID_MATCHING_CRITERIA
|
||||
]
|
||||
# When 'sources' is given as a plain string (e.g. "sources: filesystem"
|
||||
# instead of "sources: [filesystem]"), confuse's Pairs template
|
||||
# iterates over individual characters instead of treating it as a
|
||||
# single-item list. Normalize to a list first via as_str_seq().
|
||||
raw_sources = self.config["sources"].get()
|
||||
if isinstance(raw_sources, str):
|
||||
self.config["sources"].set(raw_sources.split())
|
||||
sources = sanitize_pairs(
|
||||
self.config["sources"].as_pairs(default_value="*"),
|
||||
available_sources,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ Bug fixes
|
|||
- :ref:`replace`: Made ``drive_sep_replace`` regex logic more precise to prevent
|
||||
edge-case mismatches (e.g., a song titled "1:00 AM" would incorrectly be
|
||||
considered a Windows drive path).
|
||||
- :doc:`plugins/fetchart`: Fix ``sources`` config given as a plain string
|
||||
(e.g. ``sources: filesystem``) being parsed character-by-character instead of
|
||||
as a single source name. :bug:`6336`
|
||||
- :doc:`plugins/fish`: Fix AttributeError. :bug:`6340`
|
||||
- :ref:`import-cmd` Autotagging by explicit release or recording IDs now keeps
|
||||
candidates from all enabled metadata sources instead of dropping matches when
|
||||
|
|
|
|||
|
|
@ -1047,3 +1047,28 @@ class EnforceRatioConfigTest(unittest.TestCase):
|
|||
def test_percent(self):
|
||||
self._load_with_config("0% 0.00% 5.1% 5% 100%".split(), False)
|
||||
self._load_with_config("00% 1.234% foo5% 100.1%".split(), True)
|
||||
|
||||
|
||||
class SourcesConfigTest(unittest.TestCase):
|
||||
"""Test that the 'sources' config option handles both list and plain
|
||||
string values correctly.
|
||||
"""
|
||||
|
||||
def test_sources_as_list(self):
|
||||
config["fetchart"]["sources"] = ["filesystem"]
|
||||
plugin = fetchart.FetchArtPlugin()
|
||||
assert len(plugin.sources) == 1
|
||||
assert isinstance(plugin.sources[0], fetchart.FileSystem)
|
||||
|
||||
def test_sources_as_string(self):
|
||||
config["fetchart"]["sources"] = "filesystem"
|
||||
plugin = fetchart.FetchArtPlugin()
|
||||
assert len(plugin.sources) == 1
|
||||
assert isinstance(plugin.sources[0], fetchart.FileSystem)
|
||||
|
||||
def test_sources_as_space_separated_string(self):
|
||||
config["fetchart"]["sources"] = "filesystem coverart"
|
||||
plugin = fetchart.FetchArtPlugin()
|
||||
ids = [type(s).ID for s in plugin.sources]
|
||||
assert "filesystem" in ids
|
||||
assert "coverart" in ids
|
||||
|
|
|
|||
Loading…
Reference in a new issue