Skip to content

Commit 99f7e94

Browse files
committed
Add Distance and current_metadata to autotag.__init__ for backward compat
1 parent cb246c2 commit 99f7e94

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

beets/autotag/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
from typing import TYPE_CHECKING, Union
2020

2121
from beets import config, logging
22+
from beets.util import get_most_common_tags as current_metadata
2223

2324
# Parts of external interface.
2425
from beets.util import unique_list
2526

27+
from .distance import Distance
2628
from .hooks import AlbumInfo, AlbumMatch, TrackInfo, TrackMatch
2729
from .match import Proposal, Recommendation, tag_album, tag_item
2830

@@ -34,13 +36,15 @@
3436
__all__ = [
3537
"AlbumInfo",
3638
"AlbumMatch",
37-
"TrackInfo",
38-
"TrackMatch",
39+
"Distance", # for backwards compatibility
3940
"Proposal",
4041
"Recommendation",
42+
"TrackInfo",
43+
"TrackMatch",
4144
"apply_album_metadata",
4245
"apply_item_metadata",
4346
"apply_metadata",
47+
"current_metadata", # for backwards compatibility
4448
"tag_album",
4549
"tag_item",
4650
]

beets/plugins.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
import beets
3939
from beets import logging
40-
from beets.autotag.distance import Distance
4140
from beets.util.id_extractors import extract_release_id
4241

4342
if TYPE_CHECKING:
@@ -55,6 +54,7 @@
5554
from confuse import ConfigView
5655

5756
from beets.autotag import AlbumInfo, TrackInfo
57+
from beets.autotag.distance import Distance
5858
from beets.dbcore import Query
5959
from beets.dbcore.db import FieldQueryType
6060
from beets.dbcore.types import Type
@@ -225,6 +225,8 @@ def track_distance(
225225
"""Should return a Distance object to be added to the
226226
distance for every track comparison.
227227
"""
228+
from beets.autotag.distance import Distance
229+
228230
return Distance()
229231

230232
def album_distance(
@@ -236,6 +238,8 @@ def album_distance(
236238
"""Should return a Distance object to be added to the
237239
distance for every album-level comparison.
238240
"""
241+
from beets.autotag.distance import Distance
242+
239243
return Distance()
240244

241245
def candidates(
@@ -455,6 +459,8 @@ def track_distance(item: Item, info: TrackInfo) -> Distance:
455459
"""Gets the track distance calculated by all loaded plugins.
456460
Returns a Distance object.
457461
"""
462+
from beets.autotag.distance import Distance
463+
458464
dist = Distance()
459465
for plugin in find_plugins():
460466
dist.update(plugin.track_distance(item, info))
@@ -467,6 +473,8 @@ def album_distance(
467473
mapping: dict[Item, TrackInfo],
468474
) -> Distance:
469475
"""Returns the album distance calculated by plugins."""
476+
from beets.autotag.distance import Distance
477+
470478
dist = Distance()
471479
for plugin in find_plugins():
472480
dist.update(plugin.album_distance(items, album_info, mapping))
@@ -653,6 +661,8 @@ def get_distance(
653661
"""Returns the ``data_source`` weight and the maximum source weight
654662
for albums or individual tracks.
655663
"""
664+
from beets.autotag.distance import Distance
665+
656666
dist = Distance()
657667
if info.data_source == data_source:
658668
dist.add("source", config["source_weight"].as_number())

0 commit comments

Comments
 (0)