mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-11-04 21:16:10 +06:00
tools v3.7
This commit is contained in:
parent
427137b0fe
commit
867ac35b45
|
@ -224,13 +224,11 @@ def pidFromSerial(s, l):
|
||||||
|
|
||||||
# Parse the EXTH header records and use the Kindle serial number to calculate the book pid.
|
# Parse the EXTH header records and use the Kindle serial number to calculate the book pid.
|
||||||
def getKindlePid(pidlst, rec209, token, serialnum):
|
def getKindlePid(pidlst, rec209, token, serialnum):
|
||||||
|
# Compute book PID
|
||||||
if rec209 != None and token != None:
|
pidHash = SHA1(serialnum+rec209+token)
|
||||||
# Compute book PID
|
bookPID = encodePID(pidHash)
|
||||||
pidHash = SHA1(serialnum+rec209+token)
|
bookPID = checksumPid(bookPID)
|
||||||
bookPID = encodePID(pidHash)
|
pidlst.append(bookPID)
|
||||||
bookPID = checksumPid(bookPID)
|
|
||||||
pidlst.append(bookPID)
|
|
||||||
|
|
||||||
# compute fixed pid for old pre 2.5 firmware update pid as well
|
# compute fixed pid for old pre 2.5 firmware update pid as well
|
||||||
bookPID = pidFromSerial(serialnum, 7) + "*"
|
bookPID = pidFromSerial(serialnum, 7) + "*"
|
||||||
|
@ -276,9 +274,6 @@ def getK4Pids(pidlst, rec209, token, kInfoFile=None):
|
||||||
pidlst.append(devicePID)
|
pidlst.append(devicePID)
|
||||||
|
|
||||||
# Compute book PID
|
# Compute book PID
|
||||||
if rec209 == None or token == None:
|
|
||||||
print "\nNo EXTH record type 209 or token - Perhaps not a K4 file?"
|
|
||||||
return pidlst
|
|
||||||
|
|
||||||
# Get the kindle account token
|
# Get the kindle account token
|
||||||
kindleAccountToken = getKindleInfoValueForKey("kindle.account.tokens")
|
kindleAccountToken = getKindleInfoValueForKey("kindle.account.tokens")
|
||||||
|
|
|
@ -157,18 +157,22 @@ class TopazBook:
|
||||||
raise TpzDRMError("Parse Error : Record Names Don't Match")
|
raise TpzDRMError("Parse Error : Record Names Don't Match")
|
||||||
flags = ord(self.fo.read(1))
|
flags = ord(self.fo.read(1))
|
||||||
nbRecords = ord(self.fo.read(1))
|
nbRecords = ord(self.fo.read(1))
|
||||||
|
# print nbRecords
|
||||||
for i in range (0,nbRecords) :
|
for i in range (0,nbRecords) :
|
||||||
record = [bookReadString(self.fo), bookReadString(self.fo)]
|
keyval = bookReadString(self.fo)
|
||||||
self.bookMetadata[record[0]] = record[1]
|
content = bookReadString(self.fo)
|
||||||
|
# print keyval
|
||||||
|
# print content
|
||||||
|
self.bookMetadata[keyval] = content
|
||||||
return self.bookMetadata
|
return self.bookMetadata
|
||||||
|
|
||||||
def getPIDMetaInfo(self):
|
def getPIDMetaInfo(self):
|
||||||
keysRecord = None
|
keysRecord = self.bookMetadata.get('keys','')
|
||||||
keysRecordRecord = None
|
keysRecordRecord = ''
|
||||||
if 'keys' in self.bookMetadata:
|
if keysRecord != '':
|
||||||
keysRecord = self.bookMetadata['keys']
|
keylst = keysRecord.split(',')
|
||||||
if keysRecord in self.bookMetadata:
|
for keyval in keylst:
|
||||||
keysRecordRecord = self.bookMetadata[keysRecord]
|
keysRecordRecord += self.bookMetadata.get(keyval,'')
|
||||||
return keysRecord, keysRecordRecord
|
return keysRecord, keysRecordRecord
|
||||||
|
|
||||||
def getBookTitle(self):
|
def getBookTitle(self):
|
||||||
|
|
Binary file not shown.
|
@ -29,7 +29,7 @@ from __future__ import with_statement
|
||||||
# and import that ZIP into Calibre using its plugin configuration GUI.
|
# and import that ZIP into Calibre using its plugin configuration GUI.
|
||||||
|
|
||||||
|
|
||||||
__version__ = '2.4'
|
__version__ = '2.7'
|
||||||
|
|
||||||
class Unbuffered:
|
class Unbuffered:
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
|
@ -250,7 +250,7 @@ if not __name__ == "__main__" and inCalibre:
|
||||||
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
||||||
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
||||||
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
||||||
version = (0, 2, 4) # The version number of this plugin
|
version = (0, 2, 7) # The version number of this plugin
|
||||||
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
||||||
on_import = True # Run this plugin during the import
|
on_import = True # Run this plugin during the import
|
||||||
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
||||||
|
|
|
@ -47,8 +47,12 @@
|
||||||
# 0.25 - Fixed support for 'BOOKMOBI' type 1 encryption
|
# 0.25 - Fixed support for 'BOOKMOBI' type 1 encryption
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.27'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -176,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -191,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
@ -237,12 +242,11 @@ class MobiBook:
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def getPIDMetaInfo(self):
|
def getPIDMetaInfo(self):
|
||||||
rec209 = None
|
rec209 = ''
|
||||||
token = None
|
token = ''
|
||||||
if 209 in self.meta_array:
|
if 209 in self.meta_array:
|
||||||
rec209 = self.meta_array[209]
|
rec209 = self.meta_array[209]
|
||||||
data = rec209
|
data = rec209
|
||||||
token = ''
|
|
||||||
# The 209 data comes in five byte groups. Interpret the last four bytes
|
# The 209 data comes in five byte groups. Interpret the last four bytes
|
||||||
# of each group as a big endian unsigned integer to get a key value
|
# of each group as a big endian unsigned integer to get a key value
|
||||||
# if that key exists in the meta_array, append its contents to the token
|
# if that key exists in the meta_array, append its contents to the token
|
||||||
|
|
Binary file not shown.
|
@ -24,7 +24,7 @@
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>droplet</string>
|
<string>droplet</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>DeDRM 2.4, Copyright © 2010–2011 by Apprentice Alf and others.</string>
|
<string>DeDRM 2.5, Written 2010–2011 by Apprentice Alf and others.</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>droplet</string>
|
<string>droplet</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.4</string>
|
<string>2.5</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>dplt</string>
|
<string>dplt</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>ScriptWindowState</string>
|
<string>ScriptWindowState</string>
|
||||||
<key>positionOfDivider</key>
|
<key>positionOfDivider</key>
|
||||||
<real>0.0</real>
|
<real>0</real>
|
||||||
<key>savedFrame</key>
|
<key>savedFrame</key>
|
||||||
<string>1578 27 862 788 1440 -150 1680 1050 </string>
|
<string>1578 27 862 788 1440 -150 1680 1050 </string>
|
||||||
<key>selectedTabView</key>
|
<key>selectedTabView</key>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 362 B |
|
@ -29,7 +29,7 @@ from __future__ import with_statement
|
||||||
# and import that ZIP into Calibre using its plugin configuration GUI.
|
# and import that ZIP into Calibre using its plugin configuration GUI.
|
||||||
|
|
||||||
|
|
||||||
__version__ = '2.6'
|
__version__ = '2.7'
|
||||||
|
|
||||||
class Unbuffered:
|
class Unbuffered:
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
|
@ -250,7 +250,7 @@ if not __name__ == "__main__" and inCalibre:
|
||||||
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
||||||
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
||||||
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
||||||
version = (0, 2, 6) # The version number of this plugin
|
version = (0, 2, 7) # The version number of this plugin
|
||||||
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
||||||
on_import = True # Run this plugin during the import
|
on_import = True # Run this plugin during the import
|
||||||
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.28'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -192,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
|
|
@ -29,7 +29,7 @@ from __future__ import with_statement
|
||||||
# and import that ZIP into Calibre using its plugin configuration GUI.
|
# and import that ZIP into Calibre using its plugin configuration GUI.
|
||||||
|
|
||||||
|
|
||||||
__version__ = '2.6'
|
__version__ = '2.7'
|
||||||
|
|
||||||
class Unbuffered:
|
class Unbuffered:
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
|
@ -250,7 +250,7 @@ if not __name__ == "__main__" and inCalibre:
|
||||||
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
||||||
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
||||||
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
||||||
version = (0, 2, 6) # The version number of this plugin
|
version = (0, 2, 7) # The version number of this plugin
|
||||||
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
||||||
on_import = True # Run this plugin during the import
|
on_import = True # Run this plugin during the import
|
||||||
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.28'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -192,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
|
|
@ -29,7 +29,7 @@ from __future__ import with_statement
|
||||||
# and import that ZIP into Calibre using its plugin configuration GUI.
|
# and import that ZIP into Calibre using its plugin configuration GUI.
|
||||||
|
|
||||||
|
|
||||||
__version__ = '2.6'
|
__version__ = '2.7'
|
||||||
|
|
||||||
class Unbuffered:
|
class Unbuffered:
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
|
@ -250,7 +250,7 @@ if not __name__ == "__main__" and inCalibre:
|
||||||
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, ApprenticeAlf, etc.'
|
||||||
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
||||||
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
author = 'DiapDealer, SomeUpdates' # The author of this plugin
|
||||||
version = (0, 2, 6) # The version number of this plugin
|
version = (0, 2, 7) # The version number of this plugin
|
||||||
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
file_types = set(['prc','mobi','azw','azw1','tpz']) # The file types that this plugin will be applied to
|
||||||
on_import = True # Run this plugin during the import
|
on_import = True # Run this plugin during the import
|
||||||
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.28'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -192,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.28'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -192,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.28'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -192,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
# 0.26 - Now enables Text-To-Speech flag and sets clipping limit to 100%
|
||||||
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
# 0.27 - Correct pid metadata token generation to match that used by skindle (Thank You Bart!)
|
||||||
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
# 0.28 - slight additional changes to metadata token generation (None -> '')
|
||||||
|
# 0.29 - It seems that the ideas about when multibyte trailing characters were
|
||||||
|
# included in the encryption were wrong. They aren't for DOC compressed
|
||||||
|
# files, but they are for HUFF/CDIC compress files!
|
||||||
|
|
||||||
__version__ = '0.28'
|
__version__ = '0.29'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ class MobiBook:
|
||||||
# parse information from section 0
|
# parse information from section 0
|
||||||
self.sect = self.loadSection(0)
|
self.sect = self.loadSection(0)
|
||||||
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
self.records, = struct.unpack('>H', self.sect[0x8:0x8+2])
|
||||||
|
self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2])
|
||||||
|
|
||||||
if self.magic == 'TEXtREAd':
|
if self.magic == 'TEXtREAd':
|
||||||
print "Book has format: ", self.magic
|
print "Book has format: ", self.magic
|
||||||
|
@ -192,7 +196,7 @@ class MobiBook:
|
||||||
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5):
|
||||||
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4])
|
||||||
print "Extra Data Flags = %d" % self.extra_data_flags
|
print "Extra Data Flags = %d" % self.extra_data_flags
|
||||||
if self.mobi_version < 7:
|
if (self.mobi_version < 7) and (self.compression != 17480):
|
||||||
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
# multibyte utf8 data is included in the encryption for mobi_version 6 and below
|
||||||
# so clear that byte so that we leave it to be decrypted.
|
# so clear that byte so that we leave it to be decrypted.
|
||||||
self.extra_data_flags &= 0xFFFE
|
self.extra_data_flags &= 0xFFFE
|
||||||
|
|
Loading…
Reference in New Issue
Block a user