diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index da820cffbb..ee880000f0 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -163,7 +163,7 @@ def render_html(path_to_html, width=590, height=750, as_xhtml=True): def check_ebook_format(stream, current_guess): ans = current_guess - if current_guess.lower() in ('prc', 'mobi', 'azw', 'azw1'): + if current_guess.lower() in ('prc', 'mobi', 'azw', 'azw1', 'azw3'): stream.seek(0) if stream.read(3) == 'TPZ': ans = 'tpz' diff --git a/src/calibre/ebooks/metadata/archive.py b/src/calibre/ebooks/metadata/archive.py index b9136e5a13..e28389d7f7 100644 --- a/src/calibre/ebooks/metadata/archive.py +++ b/src/calibre/ebooks/metadata/archive.py @@ -70,7 +70,7 @@ class ArchiveExtract(FileTypePlugin): fname = fnames[0] ext = os.path.splitext(fname)[1][1:] if ext.lower() not in ('lit', 'epub', 'mobi', 'prc', 'rtf', 'pdf', - 'mp3', 'pdb', 'azw', 'azw1', 'fb2'): + 'mp3', 'pdb', 'azw', 'azw1', 'azw3', 'fb2'): return archive of = self.temporary_file('_archive_extract.'+ext) diff --git a/src/calibre/ebooks/metadata/meta.py b/src/calibre/ebooks/metadata/meta.py index 61afe3c49c..83d109fcef 100644 --- a/src/calibre/ebooks/metadata/meta.py +++ b/src/calibre/ebooks/metadata/meta.py @@ -15,7 +15,7 @@ _METADATA_PRIORITIES = [ 'html', 'htm', 'xhtml', 'xhtm', 'rtf', 'fb2', 'pdf', 'prc', 'odt', 'epub', 'lit', 'lrx', 'lrf', 'mobi', - 'rb', 'imp', 'azw', 'snb' + 'rb', 'imp', 'azw', 'azw3', 'azw1' 'snb' ] # The priorities for loading metadata from different file types @@ -85,7 +85,7 @@ def _get_metadata(stream, stream_type, use_libprs_metadata, if stream_type: stream_type = stream_type.lower() if stream_type in ('html', 'html', 'xhtml', 'xhtm', 'xml'): stream_type = 'html' - if stream_type in ('mobi', 'prc', 'azw'): + if stream_type in ('mobi', 'prc', 'azw', 'azw1', 'azw3'): stream_type = 'mobi' if stream_type in ('odt', 'ods', 'odp', 'odg', 'odf'): stream_type = 'odt' diff --git a/src/calibre/ebooks/metadata/mobi.py b/src/calibre/ebooks/metadata/mobi.py index 846015f491..e701946c01 100644 --- a/src/calibre/ebooks/metadata/mobi.py +++ b/src/calibre/ebooks/metadata/mobi.py @@ -341,11 +341,14 @@ class MetadataUpdater(object): kindle_pdoc = None share_not_sync = False if mi.author_sort and pas: - authors = mi.author_sort - update_exth_record((100, normalize(authors).encode(self.codec, 'replace'))) + # We want an EXTH field per author... + authors = mi.author_sort.split(' & ') + for author in authors: + update_exth_record((100, normalize(author).encode(self.codec, 'replace'))) elif mi.authors: - authors = ';'.join(mi.authors) - update_exth_record((100, normalize(authors).encode(self.codec, 'replace'))) + authors = mi.authors + for author in authors: + update_exth_record((100, normalize(author).encode(self.codec, 'replace'))) if mi.publisher: update_exth_record((101, normalize(mi.publisher).encode(self.codec, 'replace'))) if mi.comments: @@ -360,6 +363,7 @@ class MetadataUpdater(object): if mi.isbn: update_exth_record((104, mi.isbn.encode(self.codec, 'replace'))) if mi.tags: + # FIXME: Keep a single subject per EXTH field? subjects = '; '.join(mi.tags) update_exth_record((105, normalize(subjects).encode(self.codec, 'replace'))) diff --git a/src/calibre/ebooks/metadata/rar.py b/src/calibre/ebooks/metadata/rar.py index a9b5d45546..58ca283a1a 100644 --- a/src/calibre/ebooks/metadata/rar.py +++ b/src/calibre/ebooks/metadata/rar.py @@ -32,7 +32,7 @@ def get_metadata(stream): if stream_type: stream_type = stream_type[1:] if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', - 'rb', 'imp', 'pdf', 'lrf', 'azw'): + 'rb', 'imp', 'pdf', 'lrf', 'azw', 'azw1', 'azw3'): with TemporaryDirectory() as tdir: with CurrentDir(tdir): stream = extract_member(path, match=None, name=f, diff --git a/src/calibre/ebooks/metadata/zip.py b/src/calibre/ebooks/metadata/zip.py index 887975b993..7369d2055c 100644 --- a/src/calibre/ebooks/metadata/zip.py +++ b/src/calibre/ebooks/metadata/zip.py @@ -23,7 +23,7 @@ def get_metadata(stream): if stream_type: stream_type = stream_type[1:] if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', - 'rb', 'imp', 'pdf', 'lrf', 'azw'): + 'rb', 'imp', 'pdf', 'lrf', 'azw', 'azw1', 'azw3'): with TemporaryDirectory() as tdir: with CurrentDir(tdir): path = zf.extract(f) diff --git a/src/calibre/ebooks/mobi/writer8/exth.py b/src/calibre/ebooks/mobi/writer8/exth.py index 508b77ce5b..fa0da0d2ee 100644 --- a/src/calibre/ebooks/mobi/writer8/exth.py +++ b/src/calibre/ebooks/mobi/writer8/exth.py @@ -54,8 +54,16 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False, items = metadata[term] if term == 'creator': if prefer_author_sort: - creators = [unicode(c.file_as or c) for c in + # This is a bit hackish... We only get the first item in the creators list, + # because we only care about the file_as property, and it contains *all* the authors in every creator markup, + # so we only need one, or we end up with duplicates ;). + # We then end up with a single item in our list, that contains every authors, in author sort syntax, separated by an ' & ' character. + # That's not good enough, because we want each author in a separate entry in the list, so we just split this on every & ;). + # This way, we properly end up with multiple Creator fields in the EXTH header, one for each author, like KindleGen :). + all_creators = [unicode(c.file_as or c) for c in items][:1] + for creator in all_creators: + creators = creator.split(' & ') else: creators = [unicode(c) for c in items] items = creators diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index ef7ed7a594..4f3e9fc066 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -30,7 +30,7 @@ def get_filters(): (_('LRF Books'), ['lrf']), (_('HTML Books'), ['htm', 'html', 'xhtm', 'xhtml']), (_('LIT Books'), ['lit']), - (_('MOBI Books'), ['mobi', 'prc', 'azw']), + (_('MOBI Books'), ['mobi', 'prc', 'azw', 'azw3']), (_('Topaz books'), ['tpz','azw1']), (_('Text books'), ['txt', 'text', 'rtf']), (_('PDF Books'), ['pdf', 'azw4']), diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index d831307d9a..569c72ae55 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -446,7 +446,7 @@ class KindlePage(QWizardPage, KindleUI): if not accounts: accounts = {} for y in accounts.values(): y[2] = False - accounts[x] = ['AZW, MOBI, TPZ, PRC, AZW1', True, True] + accounts[x] = ['AZW, MOBI, TPZ, PRC, AZW1, AZW3', True, True] conf.set('accounts', accounts) def nextId(self):