mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Revert "Unified search string construction between albums and items."
This reverts commit a27cf64d4f.
This commit is contained in:
parent
a280237a83
commit
ddca7c481c
3 changed files with 21 additions and 70 deletions
|
|
@ -236,19 +236,6 @@ def _add_candidate(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _parse_search_terms_with_fallbacks(
|
|
||||||
*pairs: tuple[str | None, str],
|
|
||||||
) -> tuple[str, ...]:
|
|
||||||
"""Given pairs of (search term, fallback), return a tuple of
|
|
||||||
search terms. If **all** search terms are non-empty, return them. Otherwise,
|
|
||||||
return the fallback terms.
|
|
||||||
"""
|
|
||||||
if all(term for term, _ in pairs):
|
|
||||||
return tuple(term or default for term, default in pairs)
|
|
||||||
else:
|
|
||||||
return tuple(default for _, default in pairs)
|
|
||||||
|
|
||||||
|
|
||||||
def tag_album(
|
def tag_album(
|
||||||
items,
|
items,
|
||||||
search_artist: str | None = None,
|
search_artist: str | None = None,
|
||||||
|
|
@ -307,24 +294,23 @@ def tag_album(
|
||||||
Proposal(list(candidates.values()), rec),
|
Proposal(list(candidates.values()), rec),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Manually provided search terms or fallbacks.
|
# Search terms.
|
||||||
_search_artist, _search_album = _parse_search_terms_with_fallbacks(
|
if not (search_artist and search_album):
|
||||||
(search_artist, cur_artist),
|
# No explicit search terms -- use current metadata.
|
||||||
(search_album, cur_album),
|
search_artist, search_album = cur_artist, cur_album
|
||||||
)
|
log.debug("Search terms: {} - {}", search_artist, search_album)
|
||||||
log.debug("Search terms: {} - {}", _search_artist, _search_album)
|
|
||||||
|
|
||||||
# Is this album likely to be a "various artist" release?
|
# Is this album likely to be a "various artist" release?
|
||||||
va_likely = (
|
va_likely = (
|
||||||
(not consensus["artist"])
|
(not consensus["artist"])
|
||||||
or (_search_artist.lower() in VA_ARTISTS)
|
or (search_artist.lower() in VA_ARTISTS)
|
||||||
or any(item.comp for item in items)
|
or any(item.comp for item in items)
|
||||||
)
|
)
|
||||||
log.debug("Album might be VA: {}", va_likely)
|
log.debug("Album might be VA: {}", va_likely)
|
||||||
|
|
||||||
# Get the results from the data sources.
|
# Get the results from the data sources.
|
||||||
for matched_candidate in metadata_plugins.candidates(
|
for matched_candidate in metadata_plugins.candidates(
|
||||||
items, _search_artist, _search_album, va_likely
|
items, search_artist, search_album, va_likely
|
||||||
):
|
):
|
||||||
_add_candidate(items, candidates, matched_candidate)
|
_add_candidate(items, candidates, matched_candidate)
|
||||||
|
|
||||||
|
|
@ -336,7 +322,7 @@ def tag_album(
|
||||||
|
|
||||||
|
|
||||||
def tag_item(
|
def tag_item(
|
||||||
item: Item,
|
item,
|
||||||
search_artist: str | None = None,
|
search_artist: str | None = None,
|
||||||
search_title: str | None = None,
|
search_title: str | None = None,
|
||||||
search_ids: list[str] | None = None,
|
search_ids: list[str] | None = None,
|
||||||
|
|
@ -378,18 +364,14 @@ def tag_item(
|
||||||
else:
|
else:
|
||||||
return Proposal([], Recommendation.none)
|
return Proposal([], Recommendation.none)
|
||||||
|
|
||||||
# Manually provided search terms or fallbacks.
|
# Search terms.
|
||||||
_search_artist, _search_title = _parse_search_terms_with_fallbacks(
|
search_artist = search_artist or item.artist
|
||||||
(search_artist, item.artist),
|
search_title = search_title or item.title
|
||||||
(search_title, item.title),
|
log.debug("Item search terms: {} - {}", search_artist, search_title)
|
||||||
)
|
|
||||||
log.debug("Item search terms: {} - {}", _search_artist, _search_title)
|
|
||||||
|
|
||||||
# Get and evaluate candidate metadata.
|
# Get and evaluate candidate metadata.
|
||||||
for track_info in metadata_plugins.item_candidates(
|
for track_info in metadata_plugins.item_candidates(
|
||||||
item,
|
item, search_artist, search_title
|
||||||
_search_artist,
|
|
||||||
_search_title,
|
|
||||||
):
|
):
|
||||||
dist = track_distance(item, track_info, incl_artist=True)
|
dist = track_distance(item, track_info, incl_artist=True)
|
||||||
candidates[track_info.track_id] = hooks.TrackMatch(dist, track_info)
|
candidates[track_info.track_id] = hooks.TrackMatch(dist, track_info)
|
||||||
|
|
|
||||||
|
|
@ -35,35 +35,17 @@ def find_metadata_source_plugins() -> list[MetadataSourcePlugin]:
|
||||||
|
|
||||||
|
|
||||||
@notify_info_yielded("albuminfo_received")
|
@notify_info_yielded("albuminfo_received")
|
||||||
def candidates(
|
def candidates(*args, **kwargs) -> Iterable[AlbumInfo]:
|
||||||
items: Sequence[Item],
|
|
||||||
artist: str,
|
|
||||||
album: str,
|
|
||||||
va_likely: bool,
|
|
||||||
) -> Iterable[AlbumInfo]:
|
|
||||||
"""Return matching album candidates from all metadata source plugins."""
|
"""Return matching album candidates from all metadata source plugins."""
|
||||||
for plugin in find_metadata_source_plugins():
|
for plugin in find_metadata_source_plugins():
|
||||||
yield from plugin.candidates(
|
yield from plugin.candidates(*args, **kwargs)
|
||||||
items=items,
|
|
||||||
artist=artist,
|
|
||||||
album=album,
|
|
||||||
va_likely=va_likely,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@notify_info_yielded("trackinfo_received")
|
@notify_info_yielded("trackinfo_received")
|
||||||
def item_candidates(
|
def item_candidates(*args, **kwargs) -> Iterable[TrackInfo]:
|
||||||
item: Item,
|
"""Return matching track candidates fromm all metadata source plugins."""
|
||||||
artist: str,
|
|
||||||
title: str,
|
|
||||||
) -> Iterable[TrackInfo]:
|
|
||||||
"""Return matching track candidates from all metadata source plugins."""
|
|
||||||
for plugin in find_metadata_source_plugins():
|
for plugin in find_metadata_source_plugins():
|
||||||
yield from plugin.item_candidates(
|
yield from plugin.item_candidates(*args, **kwargs)
|
||||||
item=item,
|
|
||||||
artist=artist,
|
|
||||||
title=title,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def album_for_id(_id: str) -> AlbumInfo | None:
|
def album_for_id(_id: str) -> AlbumInfo | None:
|
||||||
|
|
@ -175,22 +157,15 @@ class MetadataSourcePlugin(BeetsPlugin, metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def item_candidates(
|
def item_candidates(
|
||||||
self,
|
self, item: Item, artist: str, title: str
|
||||||
item: Item,
|
|
||||||
artist: str,
|
|
||||||
title: str,
|
|
||||||
) -> Iterable[TrackInfo]:
|
) -> Iterable[TrackInfo]:
|
||||||
"""Return :py:class:`TrackInfo` candidates that match the given track.
|
"""Return :py:class:`TrackInfo` candidates that match the given track.
|
||||||
|
|
||||||
Used in the autotag functionality to search for tracks.
|
Used in the autotag functionality to search for tracks.
|
||||||
|
|
||||||
:param item: Track item
|
:param item: Track item
|
||||||
:param artist: Track artist, either a search manually provided or
|
:param artist: Track artist
|
||||||
preprocessed from the item. If no metadata is available an empty string
|
:param title: Track title
|
||||||
is passed.
|
|
||||||
:param title: Track title, either a search manually provided or
|
|
||||||
preprocessed from the item. If no metadata is available an empty string
|
|
||||||
is passed.
|
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,6 @@ For packagers:
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
- Standardized ``search_*`` parameter handling in autotag matchers. Manual album
|
|
||||||
and singleton searches now behave consistently: when a user does not specify a
|
|
||||||
search query in the prompt, the system defaults to using the corresponding
|
|
||||||
value from the metadata. This was already the case for albums but not for
|
|
||||||
singletons.
|
|
||||||
|
|
||||||
2.5.1 (October 14, 2025)
|
2.5.1 (October 14, 2025)
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue