diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index d9ce18ddc0..77cfaaedf5 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -16,3 +16,12 @@ defaults. # next - Next available number # const - Assign the number 1 always series_index_auto_increment = 'next' + + + +# The algorithm used to copy author to author_sort +# Possible values are: +# invert: use "fn ln" -> "ln, fn" (the original algorithm) +# copy : copy author to author_sort without modification +# comma : use 'copy' if there is a ',' in the name, otherwise use 'invert' +author_sort_copy_method = 'invert' diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index 38e4a1ecd3..3af486352a 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -10,9 +10,10 @@ import os, mimetypes, sys, re from urllib import unquote, quote from urlparse import urlparse - from calibre import relpath +from calibre.utils.config import tweaks + _author_pat = re.compile(',?\s+(and|with)\s+', re.IGNORECASE) def string_to_authors(raw): raw = raw.replace('&&', u'\uffff') @@ -27,6 +28,9 @@ def authors_to_string(authors): return '' def author_to_author_sort(author): + method = tweaks['author_sort_copy_method'] + if method == 'copy' or (method == 'comma' and author.count(',') > 0): + return author tokens = author.split() tokens = tokens[-1:] + tokens[:-1] if len(tokens) > 1: