mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 22:23:42 +02:00
Catalogs: Auto generate author sort when missing
This commit is contained in:
commit
9ba8790663
1 changed files with 9 additions and 1 deletions
|
|
@ -840,7 +840,7 @@ def fetchBooksByTitle(self):
|
|||
this_title['title_sort'] = self.generateSortTitle(title)
|
||||
this_title['author'] = " & ".join(record['authors'])
|
||||
this_title['author_sort'] = record['author_sort'] if len(record['author_sort']) \
|
||||
else this_title['author']
|
||||
else self.author_to_author_sort(this_title['author'])
|
||||
this_title['id'] = record['id']
|
||||
if record['publisher']:
|
||||
this_title['publisher'] = re.sub('&', '&', record['publisher'])
|
||||
|
|
@ -1983,6 +1983,14 @@ def writeNCX(self):
|
|||
outfile.write(self.ncxSoup.prettify())
|
||||
|
||||
# Helpers
|
||||
def author_to_author_sort(self, author):
|
||||
tokens = author.split()
|
||||
tokens = tokens[-1:] + tokens[:-1]
|
||||
if len(tokens) > 1:
|
||||
tokens[0] += ','
|
||||
return ' '.join(tokens)
|
||||
|
||||
|
||||
def convertHTMLEntities(self, s):
|
||||
matches = re.findall("&#\d+;", s)
|
||||
if len(matches) > 0:
|
||||
|
|
|
|||
Loading…
Reference in a new issue