mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI Output: Use the book uuid as the ASIN field and set cdetype to EBOK to allow Amazon furthest read tracking to work with calibre generated MOBI files. Fixes #8721 (Please add support for Mobi EXTH metadata data in fields 113 and 501)
This commit is contained in:
parent
fe7b8c2376
commit
1bcef90563
@ -103,6 +103,8 @@ class EXTHHeader(object):
|
|||||||
pass
|
pass
|
||||||
elif id == 108:
|
elif id == 108:
|
||||||
pass # Producer
|
pass # Producer
|
||||||
|
elif id == 113:
|
||||||
|
pass # ASIN or UUID
|
||||||
#else:
|
#else:
|
||||||
# print 'unhandled metadata record', id, repr(content)
|
# print 'unhandled metadata record', id, repr(content)
|
||||||
|
|
||||||
|
@ -1547,6 +1547,31 @@ class MobiWriter(object):
|
|||||||
rights = 'Unknown'
|
rights = 'Unknown'
|
||||||
exth.write(pack('>II', EXTH_CODES['rights'], len(rights) + 8))
|
exth.write(pack('>II', EXTH_CODES['rights'], len(rights) + 8))
|
||||||
exth.write(rights)
|
exth.write(rights)
|
||||||
|
nrecs += 1
|
||||||
|
|
||||||
|
# Write UUID as ASIN
|
||||||
|
uuid = None
|
||||||
|
from calibre.ebooks.oeb.base import OPF
|
||||||
|
for x in oeb.metadata['identifier']:
|
||||||
|
if x.get(OPF('scheme'), None).lower() == 'uuid' or unicode(x).startswith('urn:uuid:'):
|
||||||
|
uuid = unicode(x).split(':')[-1]
|
||||||
|
break
|
||||||
|
if uuid is None:
|
||||||
|
from uuid import uuid4
|
||||||
|
uuid = str(uuid4())
|
||||||
|
|
||||||
|
if isinstance(uuid, unicode):
|
||||||
|
uuid = uuid.encode('utf-8')
|
||||||
|
exth.write(pack('>II', 113, len(uuid) + 8))
|
||||||
|
exth.write(uuid)
|
||||||
|
nrecs += 1
|
||||||
|
|
||||||
|
# Write cdetype
|
||||||
|
if not self.opts.mobi_periodical:
|
||||||
|
data = 'EBOK'
|
||||||
|
exth.write(pack('>II', 501, len(data)+8))
|
||||||
|
exth.write(data)
|
||||||
|
nrecs += 1
|
||||||
|
|
||||||
# Add a publication date entry
|
# Add a publication date entry
|
||||||
if oeb.metadata['date'] != [] :
|
if oeb.metadata['date'] != [] :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user