mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Simplified search_ids logic: now uses sequence typing
This commit is contained in:
parent
24a1d93b0e
commit
9a03789e5e
1 changed files with 9 additions and 10 deletions
|
|
@ -259,7 +259,7 @@ def tag_album(
|
||||||
items,
|
items,
|
||||||
search_artist: str = "",
|
search_artist: str = "",
|
||||||
search_album: str = "",
|
search_album: str = "",
|
||||||
search_ids: Sequence[str] | None = None,
|
search_ids: Sequence[str] = (),
|
||||||
) -> tuple[str, str, Proposal]:
|
) -> tuple[str, str, Proposal]:
|
||||||
"""Return a tuple of the current artist name, the current album
|
"""Return a tuple of the current artist name, the current album
|
||||||
name, and a `Proposal` containing `AlbumMatch` candidates.
|
name, and a `Proposal` containing `AlbumMatch` candidates.
|
||||||
|
|
@ -288,16 +288,15 @@ def tag_album(
|
||||||
candidates: dict[Any, AlbumMatch] = {}
|
candidates: dict[Any, AlbumMatch] = {}
|
||||||
|
|
||||||
# Search by explicit ID.
|
# Search by explicit ID.
|
||||||
if search_ids:
|
for search_id in search_ids:
|
||||||
for search_id in search_ids:
|
log.debug("Searching for album ID: {}", search_id)
|
||||||
log.debug("Searching for album ID: {}", search_id)
|
if info := metadata_plugins.album_for_id(search_id):
|
||||||
if info := metadata_plugins.album_for_id(search_id):
|
_add_candidate(items, candidates, info)
|
||||||
_add_candidate(items, candidates, info)
|
if opt_candidate := candidates.get(info.album_id):
|
||||||
if opt_candidate := candidates.get(info.album_id):
|
plugins.send("album_matched", match=opt_candidate)
|
||||||
plugins.send("album_matched", match=opt_candidate)
|
|
||||||
|
|
||||||
# Use existing metadata or text search.
|
# Use existing metadata or text search.
|
||||||
else:
|
if not search_ids:
|
||||||
# Try search based on current ID.
|
# Try search based on current ID.
|
||||||
if info := match_by_id(items):
|
if info := match_by_id(items):
|
||||||
_add_candidate(items, candidates, info)
|
_add_candidate(items, candidates, info)
|
||||||
|
|
@ -352,7 +351,7 @@ def tag_item(
|
||||||
item: Item,
|
item: Item,
|
||||||
search_artist: str = "",
|
search_artist: str = "",
|
||||||
search_title: str = "",
|
search_title: str = "",
|
||||||
search_ids: list[str] | None = None,
|
search_ids: Sequence[str] = (),
|
||||||
) -> Proposal:
|
) -> Proposal:
|
||||||
"""Find metadata for a single track. Return a `Proposal` consisting
|
"""Find metadata for a single track. Return a `Proposal` consisting
|
||||||
of `TrackMatch` objects.
|
of `TrackMatch` objects.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue