Fix #743533 (Enhancement: Active book highlight bar to move with metadata) and when setting metadata in MOBI files automatically create an EXTH record of type 113 if not already present to enable Amazon syncing

This commit is contained in:
Kovid Goyal 2011-03-27 19:50:43 -06:00
commit 6e80c5f200
2 changed files with 15 additions and 5 deletions

View file

@ -271,11 +271,11 @@ def hexdump(self, src, length=16):
FILTER=''.join([(len(repr(chr(x)))==3) and chr(x) or '.' for x in range(256)])
N=0; result=''
while src:
s,src = src[:length],src[length:]
hexa = ' '.join(["%02X"%ord(x) for x in s])
s = s.translate(FILTER)
result += "%04X %-*s %s\n" % (N, length*3, hexa, s)
N+=length
s,src = src[:length],src[length:]
hexa = ' '.join(["%02X"%ord(x) for x in s])
s = s.translate(FILTER)
result += "%04X %-*s %s\n" % (N, length*3, hexa, s)
N+=length
print result
def get_pdbrecords(self):
@ -323,6 +323,7 @@ def update_exth_record(rec):
"\tThis is a '%s' file of type '%s'" % (self.type[0:4], self.type[4:8]))
recs = []
added_501 = False
try:
from calibre.ebooks.conversion.config import load_defaults
prefs = load_defaults('mobi_output')
@ -355,6 +356,7 @@ def update_exth_record(rec):
update_exth_record((105, normalize(subjects).encode(self.codec, 'replace')))
if kindle_pdoc and kindle_pdoc in mi.tags:
added_501 = True
update_exth_record((501, str('PDOC')))
if mi.pubdate:
@ -370,6 +372,12 @@ def update_exth_record(rec):
update_exth_record((203, pack('>I', 0)))
if self.thumbnail_record is not None:
update_exth_record((202, pack('>I', self.thumbnail_rindex)))
# 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):
from uuid import uuid4
update_exth_record((113, str(uuid4())))
if 503 in self.original_exth_records:
update_exth_record((503, mi.title.encode(self.codec, 'replace')))

View file

@ -164,6 +164,8 @@ def edit_metadata(self, checked, bulk=None):
if d.row_delta == 0:
break
current_row += d.row_delta
self.gui.library_view.set_current_row(current_row)
self.gui.library_view.scroll_to_row(current_row)
if changed: