lastgenre: Optionally replace unicode characters when performing lookups.

This commit is contained in:
David Logie 2014-12-20 22:10:58 +00:00
parent 6756e0cda0
commit c227501a5d
2 changed files with 9 additions and 0 deletions

View file

@ -25,6 +25,8 @@ import pylast
import os
import yaml
from unidecode import unidecode
from beets import plugins
from beets import ui
from beets.util import normpath, plurality
@ -133,6 +135,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
'force': True,
'auto': True,
'separator': u', ',
'asciify': False,
})
self.setup()
@ -244,6 +247,9 @@ class LastGenrePlugin(plugins.BeetsPlugin):
if any(not s for s in args):
return None
if self.config['asciify']:
args = [unidecode(arg) for arg in args]
key = u'{0}.{1}'.format(entity, u'-'.join(unicode(a) for a in args))
if key in self._genre_cache:
return self._genre_cache[key]

View file

@ -108,6 +108,9 @@ configuration file. The available options are:
- **whitelist**: The filename of a custom genre list, ``yes`` to use
the internal whitelist, or ``no`` to consider all genres valid.
Default: ``yes``.
- **asciify**: Convert all non-ASCII characters to ASCII equivalents
when performing lookups.
Default: ``no``.
Running Manually
----------------