Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions beetsplug/fetchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,13 @@ def __init__(self) -> None:
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="*"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to simply

Suggested change
self.config["sources"].as_pairs(default_value="*"),
self.config["sources"].as_str_seq(),

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment has not been addressed @wavebyrd.

available_sources,
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/plugins/test_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,28 @@ def test_px(self):
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