This commit is contained in:
Kovid Goyal 2011-07-30 21:36:05 -06:00
parent 9f9d1ce404
commit 0f88fd4f0d

View file

@ -34,6 +34,8 @@
'rights': 109,
'type': 111,
'source': 112,
'versionnumber': 114,
'lastupdatetime': 502,
'title': 503,
}
@ -329,7 +331,7 @@ def generate_record0(self): # MOBI header {{{
if self.indexer.is_flat_periodical:
bt = 0x102
elif self.indexer.is_periodical:
bt = 0x103
bt = 0x101
record0.write(pack(b'>IIIII',
0xe8, bt, 65001, uid, 6))
@ -500,10 +502,12 @@ def build_exth(self): # EXTH Header {{{
# Write cdetype
if self.is_periodical:
data = b'NWPR'
else:
data = b'EBOK'
exth.write(pack(b'>II', 501, len(data)+8))
exth.write(data)
nrecs += 1
exth.write(pack(b'>II', 501, len(data)+8))
exth.write(data)
nrecs += 1
# Add a publication date entry
if oeb.metadata['date']:
@ -511,18 +515,28 @@ def build_exth(self): # EXTH Header {{{
elif oeb.metadata['timestamp']:
datestr = str(oeb.metadata['timestamp'][0])
if datestr is not None:
datestr = bytes(datestr)
exth.write(pack(b'>II', EXTH_CODES['pubdate'], len(datestr) + 8))
if datestr is None:
raise ValueError("missing date or timestamp")
datestr = bytes(datestr)
exth.write(pack(b'>II', EXTH_CODES['pubdate'], len(datestr) + 8))
exth.write(datestr)
nrecs += 1
if self.is_periodical:
exth.write(pack(b'>II', EXTH_CODES['lastupdatetime'], len(datestr) + 8))
exth.write(datestr)
nrecs += 1
else:
raise NotImplementedError("missing date or timestamp needed for mobi_periodical")
exth.write(pack(b'>III', EXTH_CODES['versionnumber'], 12, 7))
nrecs += 1
# Write the same creator info as kindlegen 1.2
for code, val in [(204, 201), (205, 1), (206, 2), (207, 33307)]:
exth.write(pack(b'>II', code, 12))
exth.write(pack(b'>I', val))
if self.is_periodical:
# Pretend to be amazon's super secret periodical generator
vals = {204:201, 205:2, 206:0, 207:101}
else:
# Pretend to be kindlegen 1.2
vals = {204:201, 205:1, 206:2, 207:33307}
for code, val in vals:
exth.write(pack(b'>III', code, 12, val))
nrecs += 1
if (oeb.metadata.cover and