diff --git a/plugins/genre_mapper/__init__.py b/plugins/genre_mapper/__init__.py index 2ca4d717..7e72ce5f 100644 --- a/plugins/genre_mapper/__init__.py +++ b/plugins/genre_mapper/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2022-2023 Bob Swift (rdswift) +# Copyright (C) 2022-2024 Bob Swift (rdswift) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -28,8 +28,8 @@

Please see the user guide on GitHub for more information. ''' -PLUGIN_VERSION = '0.5' -PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.3', '2.6', '2.7', '2.8', '2.9'] +PLUGIN_VERSION = '0.6' +PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.3', '2.6', '2.7', '2.8', '2.9', '2.10', '2.11'] PLUGIN_LICENSE = "GPL-2.0" PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.txt" @@ -147,21 +147,24 @@ def track_genre_mapper(album, metadata, *args): if not config.setting[OPT_MATCH_ENABLED]: return if 'genre' not in metadata or not metadata['genre']: - log.debug("%s: No genres found for: \"%s\"", PLUGIN_NAME, metadata['title'],) + log.debug('%s: No genres found for: "%s"', PLUGIN_NAME, metadata['title'],) return genre_joiner = config.setting[OPT_GENRE_SEPARATOR] if config.setting[OPT_GENRE_SEPARATOR] else MULTI_VALUED_JOINER genres = set() metadata_genres = str(metadata['genre']).split(genre_joiner) for genre in metadata_genres: for (original, replacement) in GenreMappingPairs.pairs: - if genre and re.search(original, genre, re.IGNORECASE): - genre = replacement - if config.setting[OPT_MATCH_FIRST]: - break + try: + if genre and re.search(original, genre, re.IGNORECASE): + genre = replacement + if config.setting[OPT_MATCH_FIRST]: + break + except re.error: + log.error('%s: Invalid regular expression ignored: "%s"', PLUGIN_NAME, original,) if genre: genres.add(genre.title()) genres = sorted(genres) - log.debug("{0}: Genres updated from {1} to {2}".format(PLUGIN_NAME, metadata_genres, genres,)) + log.debug('%s: Genres updated from %s to %s', PLUGIN_NAME, metadata_genres, genres,) metadata['genre'] = genres