Fix reading metadata from filenames when the author regexp does not match anything

This commit is contained in:
Kovid Goyal 2011-09-27 09:41:55 -06:00
parent c0dc8bc5e0
commit 5ec89c0e9e
2 changed files with 16 additions and 13 deletions

View File

@ -22,6 +22,8 @@ except:
_author_pat = re.compile(r'(?i),?\s+(and|with)\s+')
def string_to_authors(raw):
if not raw:
return []
raw = raw.replace('&&', u'\uffff')
raw = _author_pat.sub('&', raw)
authors = [a.strip().replace(u'\uffff', '&') for a in raw.split('&')]

View File

@ -149,6 +149,7 @@ def metadata_from_filename(name, pat=None):
try:
au = match.group('author')
aus = string_to_authors(au)
if aus:
mi.authors = aus
if prefs['swap_author_names'] and mi.authors:
def swap(a):