mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 03:52:51 +01:00
Merge pull request #37 from nidico/master
Allow unicode in rewrite items
This commit is contained in:
commit
fc06ded87b
2 changed files with 4 additions and 3 deletions
|
|
@ -27,6 +27,7 @@ import logging
|
|||
import sqlite3
|
||||
import errno
|
||||
import re
|
||||
import codecs
|
||||
|
||||
from beets import library
|
||||
from beets import plugins
|
||||
|
|
@ -673,7 +674,7 @@ def main(args=None, configfh=None):
|
|||
if configpath:
|
||||
configpath = util.syspath(configpath)
|
||||
if os.path.exists(util.syspath(configpath)):
|
||||
configfh = open(configpath)
|
||||
configfh = codecs.open(configpath, 'r', encoding='utf-8')
|
||||
else:
|
||||
configfh = None
|
||||
if configfh:
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ def rewriter(field, rules):
|
|||
def fieldfunc(item):
|
||||
value = getattr(item, field)
|
||||
for pattern, replacement in rules:
|
||||
if pattern.match(value):
|
||||
if pattern.match(value.lower()):
|
||||
# Rewrite activated.
|
||||
return replacement
|
||||
# Not activated; return original value.
|
||||
|
|
@ -59,7 +59,7 @@ class RewritePlugin(BeetsPlugin):
|
|||
raise ui.UserError("invalid field name (%s) in rewriter" %
|
||||
fieldname)
|
||||
log.debug(u'adding template field %s' % key)
|
||||
pattern = re.compile(pattern, re.I)
|
||||
pattern = re.compile(pattern.lower())
|
||||
rules[fieldname].append((pattern, value))
|
||||
if fieldname == 'artist':
|
||||
# Special case for the artist field: apply the same
|
||||
|
|
|
|||
Loading…
Reference in a new issue