mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Prevent erros when both author and author_sort are used ina template for reading metadata from filenames for files on a device
This commit is contained in:
commit
055690844a
@ -402,14 +402,12 @@ class USBMS(CLI, Device):
|
|||||||
def build_template_regexp(cls):
|
def build_template_regexp(cls):
|
||||||
def replfunc(match, seen=None):
|
def replfunc(match, seen=None):
|
||||||
v = match.group(1)
|
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:
|
if v not in seen:
|
||||||
seen |= set([v])
|
seen.add(v)
|
||||||
return '(?P<' + v + '>.+?)'
|
return '(?P<' + v + '>.+?)'
|
||||||
elif v in ['authors', 'author_sort']:
|
|
||||||
if v not in seen:
|
|
||||||
seen |= set([v])
|
|
||||||
return '(?P<author>.+?)'
|
|
||||||
return '(.+?)'
|
return '(.+?)'
|
||||||
s = set()
|
s = set()
|
||||||
f = functools.partial(replfunc, seen=s)
|
f = functools.partial(replfunc, seen=s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user