mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Invoke album_matched hook from AlbumMatch.__post_init__
This commit is contained in:
parent
5367c71d94
commit
f1204aa81f
2 changed files with 6 additions and 7 deletions
|
|
@ -22,6 +22,8 @@ from typing import TYPE_CHECKING, Any, TypeVar
|
||||||
|
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
from beets import plugins
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from beets.library import Item
|
from beets.library import Item
|
||||||
|
|
||||||
|
|
@ -246,6 +248,9 @@ class AlbumMatch(Match):
|
||||||
extra_items: list[Item]
|
extra_items: list[Item]
|
||||||
extra_tracks: list[TrackInfo]
|
extra_tracks: list[TrackInfo]
|
||||||
|
|
||||||
|
def __post_init__(self) -> None:
|
||||||
|
plugins.send("album_matched", match=self)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class TrackMatch(Match):
|
class TrackMatch(Match):
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from typing import TYPE_CHECKING, NamedTuple, TypeVar
|
||||||
import lap
|
import lap
|
||||||
import numpy as np
|
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.autotag import AlbumInfo, AlbumMatch, TrackInfo, TrackMatch, hooks
|
||||||
from beets.util import get_most_common_tags
|
from beets.util import get_most_common_tags
|
||||||
|
|
||||||
|
|
@ -272,8 +272,6 @@ def tag_album(
|
||||||
log.debug("Searching for album ID: {}", search_id)
|
log.debug("Searching for album ID: {}", search_id)
|
||||||
for _info in metadata_plugins.albums_for_ids(search_id):
|
for _info in metadata_plugins.albums_for_ids(search_id):
|
||||||
_add_candidate(items, candidates, _info)
|
_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.
|
# Use existing metadata or text search.
|
||||||
else:
|
else:
|
||||||
|
|
@ -282,8 +280,6 @@ def tag_album(
|
||||||
likelies["mb_albumid"], consensus["mb_albumid"]
|
likelies["mb_albumid"], consensus["mb_albumid"]
|
||||||
):
|
):
|
||||||
_add_candidate(items, candidates, info)
|
_add_candidate(items, candidates, info)
|
||||||
for candidate in candidates.values():
|
|
||||||
plugins.send("album_matched", match=candidate)
|
|
||||||
|
|
||||||
rec = _recommendation(list(candidates.values()))
|
rec = _recommendation(list(candidates.values()))
|
||||||
log.debug("Album ID match recommendation is {}", rec)
|
log.debug("Album ID match recommendation is {}", rec)
|
||||||
|
|
@ -318,8 +314,6 @@ def tag_album(
|
||||||
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)
|
||||||
if opt_candidate := candidates.get(matched_candidate.identifier):
|
|
||||||
plugins.send("album_matched", match=opt_candidate)
|
|
||||||
|
|
||||||
log.debug("Evaluating {} candidates.", len(candidates))
|
log.debug("Evaluating {} candidates.", len(candidates))
|
||||||
# Sort and get the recommendation.
|
# Sort and get the recommendation.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue