From: Marcel van der Veldt Date: Sun, 11 Aug 2024 15:39:34 +0000 (+0200) Subject: Improve metadata handling (#1553) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=e71ff4f8a6e7e1686613fc6fd52cb441c0113a64;p=music-assistant-server.git Improve metadata handling (#1553) --- diff --git a/music_assistant/server/controllers/metadata.py b/music_assistant/server/controllers/metadata.py index 84fb4a6b..d5fc57b0 100644 --- a/music_assistant/server/controllers/metadata.py +++ b/music_assistant/server/controllers/metadata.py @@ -151,7 +151,9 @@ class MetaDataController(CoreController): "This will allow Music Assistant to fetch additional metadata from (enabled) " "metadata providers, such as The Audio DB and Fanart.tv.\n\n" "Note that these online sources are only queried when no information is already " - "available from local files or the music providers.\n\n" + "available from local files or the music providers and local artwork/metadata " + "will always have preference over online sources so consider metadata from online " + "sources as complementary only.\n\n" "The retrieval of additional rich metadata is a process that is executed slowly " "in the background to not overload these free services with requests. " "You can speedup the process by storing the images and other metadata locally.", diff --git a/music_assistant/server/helpers/api.py b/music_assistant/server/helpers/api.py index 0b24b5cc..c5b782e7 100644 --- a/music_assistant/server/helpers/api.py +++ b/music_assistant/server/helpers/api.py @@ -30,10 +30,19 @@ class APICommandHandler: cls, command: str, func: Callable[..., Coroutine[Any, Any, Any]] ) -> APICommandHandler: """Parse APICommandHandler by providing a function.""" + type_hints = get_type_hints(func) + # workaround for generic typevar ItemCls that needs to be resolved + # to the real media item type. TODO: find a better way to do this + # without this hack + for key, value in type_hints.items(): + if not hasattr(value, "__name__"): + continue + if value.__name__ == "ItemCls": + type_hints[key] = func.__self__.item_cls return APICommandHandler( command=command, signature=inspect.signature(func), - type_hints=get_type_hints(func), + type_hints=type_hints, target=func, ) @@ -148,6 +157,7 @@ def parse_value(name: str, value: Any, value_type: Any, default: Any = MISSING) return float(value) if value_type is int and isinstance(value, str) and value.isnumeric(): return int(value) + if not isinstance(value, value_type): # type: ignore[arg-type] msg = ( f"Value {value} of type {type(value)} is invalid for {name}, "