From 61340f3e8694a7649f7587ddb91e7426ba40d00b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 6 Jan 2012 17:33:59 +0530 Subject: [PATCH] Do not error out when getting metadata for authors if the author name has either ::: or :#: in it. Fixes #912713 (":::" in authors -> exception) --- src/calibre/library/database2.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 1095774070..d55c1e0741 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -911,11 +911,18 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): aum = [] aus = {} aul = {} - for (author, author_sort, link) in aut_list: - aut = author.replace('|', ',') - aum.append(aut) - aus[aut] = author_sort.replace('|', ',') - aul[aut] = link + try: + for (author, author_sort, link) in aut_list: + aut = author.replace('|', ',') + aum.append(aut) + aus[aut] = author_sort.replace('|', ',') + aul[aut] = link + except ValueError: + # Author has either ::: or :#: in it + for x in row[fm['authors']].split(','): + aum.append(x.replace('|', ',')) + aul[aum[-1]] = '' + aus[aum[-1]] = aum[-1] mi.title = row[fm['title']] mi.authors = aum mi.author_sort = row[fm['author_sort']]