Skip to content

Commit

Permalink
Version to 6.6.3 with update for kindle book name cleanup and .kinf20…
Browse files Browse the repository at this point in the history
…18 support (initial)
  • Loading branch information
apprenticeharper committed Mar 30, 2019
1 parent b17b913 commit 3d0aa17
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>6.6.2</string>
<string>6.6.3</string>
<key>CFBundleSignature</key>
<string>dplt</string>
<key>LSMinimumSystemVersionByArchitecture</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# DeDRM.pyw
# Copyright 2010-2016 some_updates, Apprentice Alf and Apprentice Harper
# Copyright 2010-2019 some_updates, Apprentice Alf and Apprentice Harper

# Revision history:
# 6.0.0 - Release along with unified plugin
Expand Down Expand Up @@ -34,8 +34,9 @@
# 6.6.0 - Initial KFX support from TomThumb
# 6.6.1 - Standalong app fix from wzyboy
# 6.6.2 - Version bump for 64-bit Mac OS X app and various fixes.
# 6.6.3 - Version bump for Kindle book name fixes and start of support for .kinf2018

__version__ = '6.6.2'
__version__ = '6.6.3'

import sys
import os, os.path
Expand Down
6 changes: 4 additions & 2 deletions dedrm_src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from __future__ import with_statement

# __init__.py for DeDRM_plugin
# Copyright © 2008-2018 Apprentice Harper et al.
# Copyright © 2008-2019 Apprentice Harper et al.

__license__ = 'GPL v3'
__version__ = '6.6.3'
__docformat__ = 'restructuredtext en'


Expand Down Expand Up @@ -67,14 +68,15 @@
# imported format was azw8 since that may be converted to kfx)
# 6.6.1 - Thanks to wzyboy for a fix for stand-alone tools, and the new folder structure.
# 6.6.2 - revamp of folders to get Mac OS X app working. Updated to 64-bit app. Various fixes.
# 6.6.3 - More cleanup of kindle book names and start of support for .kinf2018


"""
Decrypt DRMed ebooks.
"""

PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 6, 2)
PLUGIN_VERSION_TUPLE = (6, 6, 3)
PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE])
# Include an html helpfile in the plugin's zipfile with the following name.
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
Expand Down
18 changes: 12 additions & 6 deletions dedrm_src/k4mobidedrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from __future__ import with_statement

# k4mobidedrm.py
# Copyright © 2008-2017 by Apprentice Harper et al.
# Copyright © 2008-2019 by Apprentice Harper et al.

__license__ = 'GPL v3'
__version__ = '5.5'
__version__ = '5.7'

# Engine to remove drm from Kindle and Mobipocket ebooks
# for personal use for archiving and converting your ebooks
Expand Down Expand Up @@ -60,7 +60,8 @@
# 5.3 - Changed Android support to allow passing of backup .ab files
# 5.4 - Recognise KFX files masquerading as azw, even if we can't decrypt them yet.
# 5.5 - Added GPL v3 licence explicitly.
# 5.x - Invoke KFXZipBook to handle zipped KFX files
# 5.6 - Invoke KFXZipBook to handle zipped KFX files
# 5.7 - Revamp cleanup_name

import sys, os, re
import csv
Expand Down Expand Up @@ -155,19 +156,24 @@ def unicode_argv():
# added in removal of control (<32) chars
# and removal of . at start and end
# and with some (heavily edited) code from Paul Durrant's kindlenamer.py
# and some improvements suggested by jhaisley
def cleanup_name(name):
# substitute filename unfriendly characters
name = name.replace(u"<",u"[").replace(u">",u"]").replace(u" : ",u" – ").replace(u": ",u" – ").replace(u":",u"—").replace(u"/",u"_").replace(u"\\",u"_").replace(u"|",u"_").replace(u"\"",u"\'").replace(u"*",u"_").replace(u"?",u"")
# delete control characters
name = u"".join(char for char in name if ord(char)>=32)
# white space to single space, delete leading and trailing while space
name = re.sub(ur"\s", u" ", name).strip()
# delete control characters
name = u"".join(char for char in name if ord(char)>=32)
# delete non-ascii characters
name = u"".join(char for char in name if ord(char)<=126)
# remove leading dots
while len(name)>0 and name[0] == u".":
name = name[1:]
# remove trailing dots (Windows doesn't like them)
if name.endswith(u'.'):
while name.endswith(u'.'):
name = name[:-1]
if len(name)==0:
name=u"DecryptedBook"
return name

# must be passed unicode
Expand Down
10 changes: 9 additions & 1 deletion dedrm_src/kindlekey.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Copyright © 2008-2017 Apprentice Harper et al.

__license__ = 'GPL v3'
__version__ = '2.5'
__version__ = '2.6'

# Revision history:
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
Expand All @@ -28,6 +28,7 @@
# 2.3 - Added more field names thanks to concavegit's KFX code.
# 2.4 - Fix for complex Mac disk setups, thanks to Tibs
# 2.5 - Final Fix for Windows user names with non-ascii characters, thanks to oneofusoneofus
# 2.6 - Start adding support for Kindle 2.25+ .kinf2018 file


"""
Expand Down Expand Up @@ -973,6 +974,13 @@ def getKindleInfoFiles():
# Probably not the best. To Fix (shouldn't ignore in encoding) or use utf-8
print(u'searching for kinfoFiles in ' + path.encode('ascii', 'ignore'))

# look for (K4PC 2.25.1and later) .kinf2018 file
kinfopath = path +'\\Amazon\\Kindle\\storage\\.kinf2018'
if os.path.isfile(kinfopath):
found = True
print('Found K4PC 2.25+ kinf2018 file: ' + kinfopath.encode('ascii','ignore'))
kInfoFiles.append(kinfopath)

# look for (K4PC 1.9.0 and later) .kinf2011 file
kinfopath = path +'\\Amazon\\Kindle\\storage\\.kinf2011'
if os.path.isfile(kinfopath):
Expand Down

0 comments on commit 3d0aa17

Please sign in to comment.