From d9673ef9b5e1456cc5da2a600465e1587ba885df Mon Sep 17 00:00:00 2001 From: David Logie Date: Fri, 26 Dec 2014 14:08:22 +0000 Subject: [PATCH] lastgenre: Only replace a small set of unicode characters. --- beetsplug/lastgenre/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index 7937db277..8d75c7e4f 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # This file is part of beets. # Copyright 2013, Adrian Sampson. # @@ -25,8 +26,6 @@ import pylast import os import yaml -from unidecode import unidecode - from beets import plugins from beets import ui from beets.util import normpath, plurality @@ -43,6 +42,10 @@ PYLAST_EXCEPTIONS = ( pylast.NetworkError, ) +REPLACE = { + u'‐': '-', +} + def deduplicate(seq): """Remove duplicates from sequence wile preserving order. @@ -250,7 +253,12 @@ class LastGenrePlugin(plugins.BeetsPlugin): if key in self._genre_cache: return self._genre_cache[key] else: - args_ascii = [unidecode(arg) for arg in args] + args_ascii = [] + for arg in args: + for k, v in REPLACE.items(): + arg = arg.replace(k, v) + args_ascii.append(arg) + for arglist in [args, args_ascii]: genre = self.fetch_genre(method(*arglist)) self._genre_cache[key] = genre