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.

This commit is contained in:
Kovid Goyal 2011-09-14 19:17:31 -06:00
parent c8a78a83bc
commit 2e994081ed
5 changed files with 20 additions and 5 deletions

View File

@ -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:

View File

@ -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):

View File

@ -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:

View File

@ -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

View File

@ -75,6 +75,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="opt_share_not_sync">
<property name="text">
<string>Enable sharing of book content via Facebook, etc. WARNING: Disables last read syncing</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">