diff --git a/beets/metadata_plugins.py b/beets/metadata_plugins.py index b808b078a..dbcd0455c 100644 --- a/beets/metadata_plugins.py +++ b/beets/metadata_plugins.py @@ -46,7 +46,13 @@ log = logging.getLogger("beets") def find_metadata_source_plugins() -> list[MetadataSourcePlugin]: """Return a list of all loaded metadata source plugins.""" # TODO: Make this an isinstance(MetadataSourcePlugin, ...) check in v3.0.0 - return [SafeProxy(p) for p in find_plugins() if hasattr(p, "data_source")] # type: ignore[misc,arg-type] + # This should also allow us to remove the type: ignore comments below. + metadata_plugins = [p for p in find_plugins() if hasattr(p, "data_source")] + + if config["raise_on_error"].get(bool): + return metadata_plugins # type: ignore[return-value] + else: + return list(map(SafeProxy, metadata_plugins)) # type: ignore[arg-type] @notify_info_yielded("albuminfo_received") @@ -419,8 +425,6 @@ class SafeProxy(base): def __handle_exception(self, func: Callable[P, R], e: Exception) -> None: """Helper function to log exceptions from metadata source plugins.""" - if config["raise_on_error"].get(bool): - raise e log.error( "Error in '{}.{}': {}", self.__plugin.data_source, @@ -435,9 +439,9 @@ class SafeProxy(base): except Exception as e: return self.__handle_exception(self.__plugin.album_for_id, e) - def track_for_id(self, track_id: str): + def track_for_id(self, *args, **kwargs): try: - return self.__plugin.track_for_id(track_id) + return self.__plugin.track_for_id(*args, **kwargs) except Exception as e: return self.__handle_exception(self.__plugin.track_for_id, e) diff --git a/docs/changelog.rst b/docs/changelog.rst index 64f69b792..3b0c83dd9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,6 +33,10 @@ Bug fixes: the default config path. :bug:`5652` - :doc:`plugins/lyrics`: Accepts strings for lyrics sources (previously only accepted a list of strings). :bug:`5962` +- Errors in metadata plugins during autotage process will now be logged but + won't crash beets anymore. If you want to raise exceptions instead, set the + new configuration option ``raise_on_error`` to ``yes`` :bug:`5903`, + :bug:`4789`. For plugin developers: