Skip to content

Commit 2da99e8

Browse files
committed
Invoke album_matched hook from AlbumMatch.__post_init__
1 parent 016661d commit 2da99e8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

beets/autotag/hooks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from typing_extensions import Self
2525

26+
from beets import plugins
2627
from beets.util import cached_classproperty
2728

2829
if TYPE_CHECKING:
@@ -265,6 +266,9 @@ class AlbumMatch(Match):
265266
extra_items: list[Item]
266267
extra_tracks: list[TrackInfo]
267268

269+
def __post_init__(self) -> None:
270+
plugins.send("album_matched", match=self)
271+
268272
@property
269273
def item_info_pairs(self) -> list[tuple[Item, TrackInfo]]:
270274
return list(self.mapping.items())

beets/autotag/match.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import lap
2525
import numpy as np
2626

27-
from beets import config, logging, metadata_plugins, plugins
27+
from beets import config, logging, metadata_plugins
2828
from beets.autotag import AlbumInfo, AlbumMatch, TrackInfo, TrackMatch, hooks
2929
from beets.util import get_most_common_tags
3030

@@ -274,8 +274,6 @@ def tag_album(
274274
log.debug("Searching for album ID: {}", search_id)
275275
for _info in metadata_plugins.albums_for_ids(search_id):
276276
_add_candidate(items, candidates, _info)
277-
if opt_candidate := candidates.get(_info.identifier):
278-
plugins.send("album_matched", match=opt_candidate)
279277

280278
# Use existing metadata or text search.
281279
else:
@@ -284,8 +282,6 @@ def tag_album(
284282
likelies["mb_albumid"], consensus["mb_albumid"]
285283
):
286284
_add_candidate(items, candidates, info)
287-
for candidate in candidates.values():
288-
plugins.send("album_matched", match=candidate)
289285

290286
rec = _recommendation(list(candidates.values()))
291287
log.debug("Album ID match recommendation is {}", rec)
@@ -320,8 +316,6 @@ def tag_album(
320316
items, search_artist, search_name, va_likely
321317
):
322318
_add_candidate(items, candidates, matched_candidate)
323-
if opt_candidate := candidates.get(matched_candidate.identifier):
324-
plugins.send("album_matched", match=opt_candidate)
325319

326320
log.debug("Evaluating {} candidates.", len(candidates))
327321
# Sort and get the recommendation.

0 commit comments

Comments
 (0)