diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 5ca52a290..ea2a1e064 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -22,6 +22,8 @@ from typing import TYPE_CHECKING, Any, TypeVar from typing_extensions import Self +from beets import plugins + if TYPE_CHECKING: from beets.library import Item @@ -246,6 +248,9 @@ class AlbumMatch(Match): extra_items: list[Item] extra_tracks: list[TrackInfo] + def __post_init__(self) -> None: + plugins.send("album_matched", match=self) + @dataclass class TrackMatch(Match): diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 95426df5a..65ffc1da9 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -24,7 +24,7 @@ from typing import TYPE_CHECKING, NamedTuple, TypeVar import lap import numpy as np -from beets import config, logging, metadata_plugins, plugins +from beets import config, logging, metadata_plugins from beets.autotag import AlbumInfo, AlbumMatch, TrackInfo, TrackMatch, hooks from beets.util import get_most_common_tags @@ -272,8 +272,6 @@ def tag_album( log.debug("Searching for album ID: {}", search_id) for _info in metadata_plugins.albums_for_ids(search_id): _add_candidate(items, candidates, _info) - if opt_candidate := candidates.get(_info.identifier): - plugins.send("album_matched", match=opt_candidate) # Use existing metadata or text search. else: @@ -282,8 +280,6 @@ def tag_album( likelies["mb_albumid"], consensus["mb_albumid"] ): _add_candidate(items, candidates, info) - for candidate in candidates.values(): - plugins.send("album_matched", match=candidate) rec = _recommendation(list(candidates.values())) log.debug("Album ID match recommendation is {}", rec) @@ -318,8 +314,6 @@ def tag_album( items, search_artist, search_album, va_likely ): _add_candidate(items, candidates, matched_candidate) - if opt_candidate := candidates.get(matched_candidate.identifier): - plugins.send("album_matched", match=opt_candidate) log.debug("Evaluating {} candidates.", len(candidates)) # Sort and get the recommendation.