tools v5.3
This commit is contained in:
@@ -19,7 +19,7 @@ class K4DeDRM(FileTypePlugin):
|
||||
description = 'Removes DRM from eInk Kindle, Kindle 4 Mac and Kindle 4 PC ebooks, and from Mobipocket ebooks. Provided by the work of many including DiapDealer, SomeUpdates, IHeartCabbages, CMBDTC, Skindle, DarkReverser, mdlnx, ApprenticeAlf, etc.'
|
||||
supported_platforms = ['osx', 'windows', 'linux'] # Platforms this plugin will run on
|
||||
author = 'DiapDealer, SomeUpdates, mdlnx, Apprentice Alf' # The author of this plugin
|
||||
version = (0, 4, 4) # The version number of this plugin
|
||||
version = (0, 4, 5) # The version number of this plugin
|
||||
file_types = set(['prc','mobi','azw','azw1','azw3','azw4','tpz']) # The file types that this plugin will be applied to
|
||||
on_import = True # Run this plugin during the import
|
||||
priority = 520 # run this plugin before earlier versions
|
||||
@@ -173,6 +173,9 @@ class K4DeDRM(FileTypePlugin):
|
||||
print " Getting PIDs from WINE"
|
||||
|
||||
outfile = os.path.join(self.alfdir + 'winepids.txt')
|
||||
# Remove any previous winepids.txt file.
|
||||
if os.path.exists(outfile):
|
||||
os.remove(outfile)
|
||||
|
||||
cmdline = 'wine python.exe ' \
|
||||
+ '"'+self.alfdir + '/getk4pcpids.py"' \
|
||||
@@ -193,19 +196,31 @@ class K4DeDRM(FileTypePlugin):
|
||||
|
||||
print cmdline
|
||||
|
||||
cmdline = cmdline.encode(sys.getfilesystemencoding())
|
||||
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=sys.stdout, stderr=STDOUT, close_fds=False)
|
||||
result = p2.wait("wait")
|
||||
print "Conversion returned ", result
|
||||
try:
|
||||
cmdline = cmdline.encode(sys.getfilesystemencoding())
|
||||
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=sys.stdout, stderr=STDOUT, close_fds=False)
|
||||
result = p2.wait("wait")
|
||||
except Exception, e:
|
||||
print "WINE subprocess error ", str(e)
|
||||
return []
|
||||
print "WINE subprocess returned ", result
|
||||
|
||||
WINEpids = []
|
||||
customvalues = file(outfile, 'r').readline().split(',')
|
||||
for customvalue in customvalues:
|
||||
customvalue = str(customvalue)
|
||||
customvalue = customvalue.strip()
|
||||
if len(customvalue) == 10 or len(customvalue) == 8:
|
||||
WINEpids.append(customvalue)
|
||||
else:
|
||||
print "'%s' is not a valid PID." % customvalue
|
||||
if os.path.exists(outfile):
|
||||
try:
|
||||
customvalues = file(outfile, 'r').readline().split(',')
|
||||
for customvalue in customvalues:
|
||||
customvalue = str(customvalue)
|
||||
customvalue = customvalue.strip()
|
||||
if len(customvalue) == 10 or len(customvalue) == 8:
|
||||
WINEpids.append(customvalue)
|
||||
else:
|
||||
print "'%s' is not a valid PID." % customvalue
|
||||
except Exception, e:
|
||||
print "Error parsing winepids.txt: ", str(e)
|
||||
return []
|
||||
else:
|
||||
print "No PIDs generated by Wine Python subprocess."
|
||||
return WINEpids
|
||||
|
||||
def is_customizable(self):
|
||||
@@ -240,4 +255,4 @@ class K4DeDRM(FileTypePlugin):
|
||||
for candidate in zf.namelist():
|
||||
if candidate in names:
|
||||
ans[candidate] = zf.read(candidate)
|
||||
return ans
|
||||
return ans
|
||||
Reference in New Issue
Block a user