Prevent exceptions when 1) both author and author_sort are used in "add" templates, and 2) books are added from a device, and 3) read metadata from file contents is not checked.

This commit is contained in:
Charles Haley 2012-04-10 18:16:42 +02:00
parent c843a1d7d0
commit e24adc0e35

View File

@ -402,14 +402,12 @@ class USBMS(CLI, Device):
def build_template_regexp(cls):
def replfunc(match, seen=None):
v = match.group(1)
if v in ['title', 'series', 'series_index', 'isbn']:
if v in ['authors', 'author_sort']:
v = 'author'
if v in ('title', 'series', 'series_index', 'isbn', 'author'):
if v not in seen:
seen |= set([v])
seen.add(v)
return '(?P<' + v + '>.+?)'
elif v in ['authors', 'author_sort']:
if v not in seen:
seen |= set([v])
return '(?P<author>.+?)'
return '(.+?)'
s = set()
f = functools.partial(replfunc, seen=s)