From 2e994081ed87430fe0559d8edac5b010bcd4916e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 14 Sep 2011 19:17:31 -0600 Subject: [PATCH] MOBI Output: Add option in Preferences->Output Options->MOBI Output to enable the share via Facebook feature for calibre produced MOBI files. Note that enabling this disables the sync last read position across multiple devices feature. Don't ask me why, ask Amazon. --- src/calibre/ebooks/metadata/mobi.py | 4 +++- src/calibre/ebooks/mobi/output.py | 5 +++++ src/calibre/ebooks/mobi/writer2/main.py | 7 ++++--- src/calibre/gui2/convert/mobi_output.py | 2 +- src/calibre/gui2/convert/mobi_output.ui | 7 +++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/metadata/mobi.py b/src/calibre/ebooks/metadata/mobi.py index 74db3b3a58..2da9f74961 100644 --- a/src/calibre/ebooks/metadata/mobi.py +++ b/src/calibre/ebooks/metadata/mobi.py @@ -330,9 +330,11 @@ class MetadataUpdater(object): prefs = load_defaults('mobi_output') pas = prefs.get('prefer_author_sort', False) kindle_pdoc = prefs.get('personal_doc', None) + share_not_sync = prefs.get('share_not_sync', False) except: pas = False 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'))) @@ -376,7 +378,7 @@ class MetadataUpdater(object): # Add a 113 record if not present to allow Amazon syncing if (113 not in self.original_exth_records and self.original_exth_records.get(501, None) == 'EBOK' and - not added_501): + not added_501 and not share_not_sync): from uuid import uuid4 update_exth_record((113, str(uuid4()))) if 503 in self.original_exth_records: diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py index 4f5d09c894..f22015d71f 100644 --- a/src/calibre/ebooks/mobi/output.py +++ b/src/calibre/ebooks/mobi/output.py @@ -55,6 +55,11 @@ class MOBIOutput(OutputFormatPlugin): ' specified directory. If the directory already ' 'exists, it will be deleted.') ), + OptionRecommendation(name='share_not_sync', recommended_value=False, + help=_('Enable sharing of book content via Facebook etc. ' + ' on the Kindle. WARNING: Using this feature means that ' + ' the book will not auto sync its last read position ' + ' on multiple devices. Complain to Amazon.')) ]) def check_for_periodical(self): diff --git a/src/calibre/ebooks/mobi/writer2/main.py b/src/calibre/ebooks/mobi/writer2/main.py index 1cda1b14dd..1705a5a342 100644 --- a/src/calibre/ebooks/mobi/writer2/main.py +++ b/src/calibre/ebooks/mobi/writer2/main.py @@ -529,9 +529,10 @@ class MobiWriter(object): if isinstance(uuid, unicode): uuid = uuid.encode('utf-8') - exth.write(pack(b'>II', 113, len(uuid) + 8)) - exth.write(uuid) - nrecs += 1 + if not self.opts.share_not_sync: + exth.write(pack(b'>II', 113, len(uuid) + 8)) + exth.write(uuid) + nrecs += 1 # Write cdetype if not self.is_periodical: diff --git a/src/calibre/gui2/convert/mobi_output.py b/src/calibre/gui2/convert/mobi_output.py index f268ac8606..cd1d0430ae 100644 --- a/src/calibre/gui2/convert/mobi_output.py +++ b/src/calibre/gui2/convert/mobi_output.py @@ -23,7 +23,7 @@ class PluginWidget(Widget, Ui_Form): Widget.__init__(self, parent, ['prefer_author_sort', 'rescale_images', 'toc_title', 'mobi_ignore_margins', 'mobi_toc_at_start', - 'dont_compress', 'no_inline_toc', + 'dont_compress', 'no_inline_toc', 'share_not_sync', 'personal_doc']#, 'mobi_navpoints_only_deepest'] ) self.db, self.book_id = db, book_id diff --git a/src/calibre/gui2/convert/mobi_output.ui b/src/calibre/gui2/convert/mobi_output.ui index 7643d791f3..68cd55ab95 100644 --- a/src/calibre/gui2/convert/mobi_output.ui +++ b/src/calibre/gui2/convert/mobi_output.ui @@ -75,6 +75,13 @@ + + + + Enable sharing of book content via Facebook, etc. WARNING: Disables last read syncing + + +