8
8
from __future__ import annotations
9
9
10
10
import abc
11
+ import inspect
11
12
import re
12
13
import sys
14
+ import warnings
13
15
from typing import TYPE_CHECKING , Generic , Literal , Sequence , TypedDict , TypeVar
14
16
15
17
from beets .util import cached_classproperty
@@ -36,11 +38,24 @@ def find_metadata_source_plugins() -> list[MetadataSourcePlugin]:
36
38
37
39
Resolved from all currently loaded beets plugins.
38
40
"""
39
- return [
40
- plugin
41
- for plugin in find_plugins ()
42
- if isinstance (plugin , MetadataSourcePlugin )
43
- ]
41
+
42
+ all_plugins = find_plugins ()
43
+ metadata_plugins = []
44
+ for plugin in all_plugins :
45
+ if isinstance (plugin , MetadataSourcePlugin ):
46
+ metadata_plugins .append (plugin )
47
+ elif hasattr (plugin , "data_source" ):
48
+ # TODO: Remove this in the future major release, v3.0.0
49
+ warnings .warn (
50
+ f"{ plugin .__class__ .__name__ } is used as a legacy metadata source. "
51
+ "It should extend MetadataSourcePlugin instead of BeetsPlugin. "
52
+ "Support for this will be removed in the v3.0.0 release!" ,
53
+ DeprecationWarning ,
54
+ stacklevel = 2 ,
55
+ )
56
+ metadata_plugins .append (plugin )
57
+
58
+ return metadata_plugins
44
59
45
60
46
61
@notify_info_yielded ("albuminfo_received" )
@@ -369,3 +384,13 @@ def item_candidates(
369
384
None ,
370
385
self .tracks_for_ids ([result ["id" ] for result in results if result ]),
371
386
)
387
+
388
+
389
+ # Dynamically copy methods to BeetsPlugin for legacy support
390
+ # TODO: Remove this in the future major release, v3.0.0
391
+
392
+ for name , method in inspect .getmembers (
393
+ MetadataSourcePlugin , predicate = inspect .isfunction
394
+ ):
395
+ if not hasattr (BeetsPlugin , name ):
396
+ setattr (BeetsPlugin , name , method )
0 commit comments