GwR revisions

This commit is contained in:
GRiker 2010-03-27 05:04:06 -07:00
parent f7108d173b
commit 9ec2940174

View File

@ -127,7 +127,6 @@ class BookHeader(object):
self.length, self.type, self.codepage, self.unique_id, \ self.length, self.type, self.codepage, self.unique_id, \
self.version = struct.unpack('>LLLLL', raw[20:40]) self.version = struct.unpack('>LLLLL', raw[20:40])
try: try:
self.codec = { self.codec = {
1252: 'cp1252', 1252: 'cp1252',
@ -154,10 +153,17 @@ class BookHeader(object):
sublangid = (langcode >> 10) & 0xFF sublangid = (langcode >> 10) & 0xFF
self.language = main_language.get(langid, 'ENGLISH') self.language = main_language.get(langid, 'ENGLISH')
self.sublanguage = sub_language.get(sublangid, 'NEUTRAL') self.sublanguage = sub_language.get(sublangid, 'NEUTRAL')
if ident == 'TEXTREAD':
self.mobi_version = 1
self.first_image_index = -1
self.exth_flag = 0
self.exth = None
else:
self.mobi_version = struct.unpack('>I', raw[0x68:0x6c])[0] self.mobi_version = struct.unpack('>I', raw[0x68:0x6c])[0]
self.first_image_index = struct.unpack('>L', raw[0x6c:0x6c + 4])[0] self.first_image_index = struct.unpack('>L', raw[0x6c:0x6c + 4])[0]
self.exth_flag, = struct.unpack('>L', raw[0x80:0x84]) self.exth_flag, = struct.unpack('>L', raw[0x80:0x84])
self.exth = None self.exth = None
if not isinstance(self.title, unicode): if not isinstance(self.title, unicode):
self.title = self.title.decode(self.codec, 'replace') self.title = self.title.decode(self.codec, 'replace')