diff --git a/Calibre_Plugins/K4MobiDeDRM_plugin/kgenpids.py b/Calibre_Plugins/K4MobiDeDRM_plugin/kgenpids.py index 6dcbf73..039daf9 100644 --- a/Calibre_Plugins/K4MobiDeDRM_plugin/kgenpids.py +++ b/Calibre_Plugins/K4MobiDeDRM_plugin/kgenpids.py @@ -224,13 +224,11 @@ def pidFromSerial(s, l): # Parse the EXTH header records and use the Kindle serial number to calculate the book pid. def getKindlePid(pidlst, rec209, token, serialnum): - - if rec209 != None and token != None: - # Compute book PID - pidHash = SHA1(serialnum+rec209+token) - bookPID = encodePID(pidHash) - bookPID = checksumPid(bookPID) - pidlst.append(bookPID) + # Compute book PID + pidHash = SHA1(serialnum+rec209+token) + bookPID = encodePID(pidHash) + bookPID = checksumPid(bookPID) + pidlst.append(bookPID) # compute fixed pid for old pre 2.5 firmware update pid as well bookPID = pidFromSerial(serialnum, 7) + "*" @@ -276,9 +274,6 @@ def getK4Pids(pidlst, rec209, token, kInfoFile=None): pidlst.append(devicePID) # 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 kindleAccountToken = getKindleInfoValueForKey("kindle.account.tokens") diff --git a/Calibre_Plugins/K4MobiDeDRM_plugin/topazextract.py b/Calibre_Plugins/K4MobiDeDRM_plugin/topazextract.py index 732bbae..59bc5fa 100644 --- a/Calibre_Plugins/K4MobiDeDRM_plugin/topazextract.py +++ b/Calibre_Plugins/K4MobiDeDRM_plugin/topazextract.py @@ -157,18 +157,22 @@ class TopazBook: raise TpzDRMError("Parse Error : Record Names Don't Match") flags = ord(self.fo.read(1)) nbRecords = ord(self.fo.read(1)) + # print nbRecords for i in range (0,nbRecords) : - record = [bookReadString(self.fo), bookReadString(self.fo)] - self.bookMetadata[record[0]] = record[1] + keyval = bookReadString(self.fo) + content = bookReadString(self.fo) + # print keyval + # print content + self.bookMetadata[keyval] = content return self.bookMetadata def getPIDMetaInfo(self): - keysRecord = None - keysRecordRecord = None - if 'keys' in self.bookMetadata: - keysRecord = self.bookMetadata['keys'] - if keysRecord in self.bookMetadata: - keysRecordRecord = self.bookMetadata[keysRecord] + keysRecord = self.bookMetadata.get('keys','') + keysRecordRecord = '' + if keysRecord != '': + keylst = keysRecord.split(',') + for keyval in keylst: + keysRecordRecord += self.bookMetadata.get(keyval,'') return keysRecord, keysRecordRecord def getBookTitle(self): diff --git a/Calibre_Plugins/k4mobidedrm_plugin.zip b/Calibre_Plugins/k4mobidedrm_plugin.zip index 0e5c337..6b49789 100644 Binary files a/Calibre_Plugins/k4mobidedrm_plugin.zip and b/Calibre_Plugins/k4mobidedrm_plugin.zip differ diff --git a/Calibre_Plugins/k4mobidedrm_plugin/k4mobidedrm_plugin.py b/Calibre_Plugins/k4mobidedrm_plugin/k4mobidedrm_plugin.py index 0255a3c..d165f37 100644 --- a/Calibre_Plugins/k4mobidedrm_plugin/k4mobidedrm_plugin.py +++ b/Calibre_Plugins/k4mobidedrm_plugin/k4mobidedrm_plugin.py @@ -29,7 +29,7 @@ from __future__ import with_statement # and import that ZIP into Calibre using its plugin configuration GUI. -__version__ = '2.4' +__version__ = '2.7' class Unbuffered: 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.' supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on 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 on_import = True # Run this plugin during the import priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm diff --git a/Calibre_Plugins/k4mobidedrm_plugin/mobidedrm.py b/Calibre_Plugins/k4mobidedrm_plugin/mobidedrm.py index ec756b9..7aef175 100644 --- a/Calibre_Plugins/k4mobidedrm_plugin/mobidedrm.py +++ b/Calibre_Plugins/k4mobidedrm_plugin/mobidedrm.py @@ -47,8 +47,12 @@ # 0.25 - Fixed support for 'BOOKMOBI' type 1 encryption # 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.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 @@ -176,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -191,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE @@ -237,12 +242,11 @@ class MobiBook: return title def getPIDMetaInfo(self): - rec209 = None - token = None + rec209 = '' + token = '' if 209 in self.meta_array: rec209 = self.meta_array[209] data = rec209 - token = '' # 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 # if that key exists in the meta_array, append its contents to the token diff --git a/DeDRM_Macintosh_Application/DeDRM.app.txt b/DeDRM_Macintosh_Application/DeDRM.app.txt index 197b274..26aa8fd 100644 Binary files a/DeDRM_Macintosh_Application/DeDRM.app.txt and b/DeDRM_Macintosh_Application/DeDRM.app.txt differ diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist index 4f3beb7..f1761ac 100644 --- a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist +++ b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist @@ -24,7 +24,7 @@ CFBundleExecutable droplet CFBundleGetInfoString - DeDRM 2.4, Copyright © 2010–2011 by Apprentice Alf and others. + DeDRM 2.5, Written 2010–2011 by Apprentice Alf and others. CFBundleIconFile droplet CFBundleInfoDictionaryVersion @@ -34,7 +34,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.4 + 2.5 CFBundleSignature dplt LSMinimumSystemVersion @@ -50,7 +50,7 @@ name ScriptWindowState positionOfDivider - 0.0 + 0 savedFrame 1578 27 862 788 1440 -150 1680 1050 selectedTabView diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/MacOS/droplet b/DeDRM_Macintosh_Application/DeDRM.app/Contents/MacOS/droplet index c715860..6a47312 100644 Binary files a/DeDRM_Macintosh_Application/DeDRM.app/Contents/MacOS/droplet and b/DeDRM_Macintosh_Application/DeDRM.app/Contents/MacOS/droplet differ diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/Scripts/main.scpt b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/Scripts/main.scpt index 80448ca..4d03f32 100644 Binary files a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/Scripts/main.scpt and b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/Scripts/main.scpt differ diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/droplet.rsrc b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/droplet.rsrc index 802f370..0601ac5 100644 Binary files a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/droplet.rsrc and b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/droplet.rsrc differ diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/k4mobidedrm.py b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/k4mobidedrm.py index 3a0000e..d165f37 100644 --- a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/k4mobidedrm.py +++ b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/k4mobidedrm.py @@ -29,7 +29,7 @@ from __future__ import with_statement # and import that ZIP into Calibre using its plugin configuration GUI. -__version__ = '2.6' +__version__ = '2.7' class Unbuffered: 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.' supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on 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 on_import = True # Run this plugin during the import priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/mobidedrm.py b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/mobidedrm.py index e660a1a..7aef175 100644 --- a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/mobidedrm.py +++ b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/mobidedrm.py @@ -48,8 +48,11 @@ # 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.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 @@ -177,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -192,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE diff --git a/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/k4mobidedrm.py b/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/k4mobidedrm.py index 3a0000e..d165f37 100644 --- a/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/k4mobidedrm.py +++ b/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/k4mobidedrm.py @@ -29,7 +29,7 @@ from __future__ import with_statement # and import that ZIP into Calibre using its plugin configuration GUI. -__version__ = '2.6' +__version__ = '2.7' class Unbuffered: 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.' supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on 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 on_import = True # Run this plugin during the import priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm diff --git a/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/mobidedrm.py b/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/mobidedrm.py index e660a1a..7aef175 100644 --- a/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/mobidedrm.py +++ b/DeDRM_Windows_Application/DeDRM_WinApp/DeDRM_lib/lib/mobidedrm.py @@ -48,8 +48,11 @@ # 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.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 @@ -177,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -192,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE diff --git a/KindleBooks_Tools/KindleBooks/lib/k4mobidedrm.py b/KindleBooks_Tools/KindleBooks/lib/k4mobidedrm.py index 3a0000e..d165f37 100644 --- a/KindleBooks_Tools/KindleBooks/lib/k4mobidedrm.py +++ b/KindleBooks_Tools/KindleBooks/lib/k4mobidedrm.py @@ -29,7 +29,7 @@ from __future__ import with_statement # and import that ZIP into Calibre using its plugin configuration GUI. -__version__ = '2.6' +__version__ = '2.7' class Unbuffered: 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.' supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on 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 on_import = True # Run this plugin during the import priority = 210 # run this plugin before mobidedrm, k4pcdedrm, k4dedrm diff --git a/KindleBooks_Tools/KindleBooks/lib/mobidedrm.py b/KindleBooks_Tools/KindleBooks/lib/mobidedrm.py index e660a1a..7aef175 100644 --- a/KindleBooks_Tools/KindleBooks/lib/mobidedrm.py +++ b/KindleBooks_Tools/KindleBooks/lib/mobidedrm.py @@ -48,8 +48,11 @@ # 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.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 @@ -177,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -192,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE diff --git a/KindleBooks_Tools/Kindle_4_Mac_Unswindle/lib/mobidedrm.py b/KindleBooks_Tools/Kindle_4_Mac_Unswindle/lib/mobidedrm.py index e660a1a..7aef175 100644 --- a/KindleBooks_Tools/Kindle_4_Mac_Unswindle/lib/mobidedrm.py +++ b/KindleBooks_Tools/Kindle_4_Mac_Unswindle/lib/mobidedrm.py @@ -48,8 +48,11 @@ # 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.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 @@ -177,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -192,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE diff --git a/KindleBooks_Tools/Kindle_4_PC_Unswindle/mobidedrm.py b/KindleBooks_Tools/Kindle_4_PC_Unswindle/mobidedrm.py index e660a1a..7aef175 100644 --- a/KindleBooks_Tools/Kindle_4_PC_Unswindle/mobidedrm.py +++ b/KindleBooks_Tools/Kindle_4_PC_Unswindle/mobidedrm.py @@ -48,8 +48,11 @@ # 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.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 @@ -177,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -192,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE diff --git a/Mobi_Additional_Tools/lib/mobidedrm.py b/Mobi_Additional_Tools/lib/mobidedrm.py index e660a1a..7aef175 100644 --- a/Mobi_Additional_Tools/lib/mobidedrm.py +++ b/Mobi_Additional_Tools/lib/mobidedrm.py @@ -48,8 +48,11 @@ # 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.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 @@ -177,6 +180,7 @@ class MobiBook: # parse information from section 0 self.sect = self.loadSection(0) self.records, = struct.unpack('>H', self.sect[0x8:0x8+2]) + self.compression, = struct.unpack('>H', self.sect[0x0:0x0+2]) if self.magic == 'TEXtREAd': print "Book has format: ", self.magic @@ -192,7 +196,7 @@ class MobiBook: if (self.mobi_length >= 0xE4) and (self.mobi_version >= 5): self.extra_data_flags, = struct.unpack('>H', self.sect[0xF2:0xF4]) 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 # so clear that byte so that we leave it to be decrypted. self.extra_data_flags &= 0xFFFE