mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Add author_sort_map to MetaInformation
This commit is contained in:
parent
4b50654ef2
commit
60219fe54c
@ -223,6 +223,7 @@ class MetaInformation(object):
|
|||||||
'isbn', 'tags', 'cover_data', 'application_id', 'guide',
|
'isbn', 'tags', 'cover_data', 'application_id', 'guide',
|
||||||
'manifest', 'spine', 'toc', 'cover', 'language',
|
'manifest', 'spine', 'toc', 'cover', 'language',
|
||||||
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc',
|
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc',
|
||||||
|
'author_sort_map',
|
||||||
'pubdate', 'rights', 'publication_type', 'uuid'):
|
'pubdate', 'rights', 'publication_type', 'uuid'):
|
||||||
if hasattr(mi, attr):
|
if hasattr(mi, attr):
|
||||||
setattr(ans, attr, getattr(mi, attr))
|
setattr(ans, attr, getattr(mi, attr))
|
||||||
@ -244,6 +245,7 @@ class MetaInformation(object):
|
|||||||
self.tags = getattr(mi, 'tags', [])
|
self.tags = getattr(mi, 'tags', [])
|
||||||
#: mi.cover_data = (ext, data)
|
#: mi.cover_data = (ext, data)
|
||||||
self.cover_data = getattr(mi, 'cover_data', (None, None))
|
self.cover_data = getattr(mi, 'cover_data', (None, None))
|
||||||
|
self.author_sort_map = getattr(mi, 'author_sort_map', {})
|
||||||
|
|
||||||
for x in ('author_sort', 'title_sort', 'comments', 'category', 'publisher',
|
for x in ('author_sort', 'title_sort', 'comments', 'category', 'publisher',
|
||||||
'series', 'series_index', 'rating', 'isbn', 'language',
|
'series', 'series_index', 'rating', 'isbn', 'language',
|
||||||
@ -258,7 +260,7 @@ class MetaInformation(object):
|
|||||||
'series', 'series_index', 'tags', 'rating', 'isbn', 'language',
|
'series', 'series_index', 'tags', 'rating', 'isbn', 'language',
|
||||||
'application_id', 'manifest', 'toc', 'spine', 'guide', 'cover',
|
'application_id', 'manifest', 'toc', 'spine', 'guide', 'cover',
|
||||||
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate',
|
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate',
|
||||||
'rights', 'publication_type', 'uuid'
|
'rights', 'publication_type', 'uuid', 'author_sort_map'
|
||||||
):
|
):
|
||||||
prints(x, getattr(self, x, 'None'))
|
prints(x, getattr(self, x, 'None'))
|
||||||
|
|
||||||
@ -288,6 +290,9 @@ class MetaInformation(object):
|
|||||||
self.tags += mi.tags
|
self.tags += mi.tags
|
||||||
self.tags = list(set(self.tags))
|
self.tags = list(set(self.tags))
|
||||||
|
|
||||||
|
if mi.author_sort_map:
|
||||||
|
self.author_sort_map.update(mi.author_sort_map)
|
||||||
|
|
||||||
if getattr(mi, 'cover_data', False):
|
if getattr(mi, 'cover_data', False):
|
||||||
other_cover = mi.cover_data[-1]
|
other_cover = mi.cover_data[-1]
|
||||||
self_cover = self.cover_data[-1] if self.cover_data else ''
|
self_cover = self.cover_data[-1] if self.cover_data else ''
|
||||||
|
@ -35,6 +35,8 @@ PUBLICATION_METADATA_FIELDS = frozenset([
|
|||||||
'title_sort',
|
'title_sort',
|
||||||
# Ordered list of authors. Must never be None, can be [_('Unknown')]
|
# Ordered list of authors. Must never be None, can be [_('Unknown')]
|
||||||
'authors',
|
'authors',
|
||||||
|
# Map of sort strings for each author
|
||||||
|
'author_sort_map',
|
||||||
# Pseudo field that can be set, but if not set is auto generated
|
# Pseudo field that can be set, but if not set is auto generated
|
||||||
# from authors and languages
|
# from authors and languages
|
||||||
'author_sort',
|
'author_sort',
|
||||||
|
@ -16,6 +16,7 @@ NULL_VALUES = {
|
|||||||
'classifiers' : {},
|
'classifiers' : {},
|
||||||
'languages' : [],
|
'languages' : [],
|
||||||
'device_collections': [],
|
'device_collections': [],
|
||||||
|
'author_sort_map': {},
|
||||||
'authors' : [_('Unknown')],
|
'authors' : [_('Unknown')],
|
||||||
'title' : _('Unknown'),
|
'title' : _('Unknown'),
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
if aum: aum = [a.strip().replace('|', ',') for a in aum.split(',')]
|
if aum: aum = [a.strip().replace('|', ',') for a in aum.split(',')]
|
||||||
mi = MetaInformation(self.title(idx, index_is_id=index_is_id), aum)
|
mi = MetaInformation(self.title(idx, index_is_id=index_is_id), aum)
|
||||||
mi.author_sort = self.author_sort(idx, index_is_id=index_is_id)
|
mi.author_sort = self.author_sort(idx, index_is_id=index_is_id)
|
||||||
mi.authors_sort_strings = self.authors_sort_strings(idx, index_is_id)
|
if mi.authors:
|
||||||
|
mi.author_sort_map = {}
|
||||||
|
for name, sort in zip(mi.authors, self.authors_sort_strings(idx,
|
||||||
|
index_is_id)):
|
||||||
|
mi.author_sort_map[name] = sort
|
||||||
mi.comments = self.comments(idx, index_is_id=index_is_id)
|
mi.comments = self.comments(idx, index_is_id=index_is_id)
|
||||||
mi.publisher = self.publisher(idx, index_is_id=index_is_id)
|
mi.publisher = self.publisher(idx, index_is_id=index_is_id)
|
||||||
mi.timestamp = self.timestamp(idx, index_is_id=index_is_id)
|
mi.timestamp = self.timestamp(idx, index_is_id=index_is_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user