Skip to content

Commit

Permalink
Use configured 'join_genres' setting to split genres.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdswift authored and phw committed Oct 24, 2023
1 parent ed40948 commit 9c8bce4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/genre_mapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 Bob Swift (rdswift)
# Copyright (C) 2022-2023 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
Expand Down Expand Up @@ -28,8 +28,8 @@
<br /><br />
Please see the <a href="https://github.com/rdswift/picard-plugins/blob/2.0_RDS_Plugins/plugins/genre_mapper/docs/README.md">user guide</a> on GitHub for more information.
'''
PLUGIN_VERSION = '0.4'
PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.3', '2.6', '2.7', '2.8']
PLUGIN_VERSION = '0.5'
PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.3', '2.6', '2.7', '2.8', '2.9']
PLUGIN_LICENSE = "GPL-2.0"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.txt"

Expand All @@ -56,6 +56,7 @@

pairs_split = re.compile(r"\r\n|\n\r|\n").split

OPT_GENRE_SEPARATOR = 'join_genres'
OPT_MATCH_ENABLED = 'genre_mapper_enabled'
OPT_MATCH_PAIRS = 'genre_mapper_replacement_pairs'
OPT_MATCH_FIRST = 'genre_mapper_apply_first_match_only'
Expand Down Expand Up @@ -148,8 +149,9 @@ def track_genre_mapper(album, metadata, *args):
if 'genre' not in metadata or not metadata['genre']:
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(MULTI_VALUED_JOINER)
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):
Expand Down

0 comments on commit 9c8bce4

Please sign in to comment.