mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-11-16 19:06:09 +06:00
Merge pull request #198 from dunesmopy/patch-1
Support multiple input Kindle files
This commit is contained in:
commit
0b244b5781
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# k4mobidedrm.py, version 5.3
|
# k4mobidedrm.py, version 5.5
|
||||||
# Copyright © 2009-2015 by ApprenticeHarper et al.
|
# Copyright © 2009-2017 by ApprenticeHarper et al.
|
||||||
|
|
||||||
# engine to remove drm from Kindle and Mobipocket ebooks
|
# engine to remove drm from Kindle and Mobipocket ebooks
|
||||||
# for personal use for archiving and converting your ebooks
|
# for personal use for archiving and converting your ebooks
|
||||||
|
@ -57,13 +57,15 @@ from __future__ import with_statement
|
||||||
# 5.2 - Fixed error in command line processing of unicode arguments
|
# 5.2 - Fixed error in command line processing of unicode arguments
|
||||||
# 5.3 - Changed Android support to allow passing of backup .ab files
|
# 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.4 - Recognise KFX files masquerading as azw, even if we can't decrypt them yet.
|
||||||
|
# 5.5 - Support multiple input files
|
||||||
|
|
||||||
__version__ = '5.4'
|
__version__ = '5.5'
|
||||||
|
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
import csv
|
import csv
|
||||||
import getopt
|
import getopt
|
||||||
|
import glob
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
import time
|
import time
|
||||||
|
@ -287,7 +289,7 @@ def decryptBook(infile, outdir, kDatabaseFiles, androidFiles, serials, pids):
|
||||||
def usage(progname):
|
def usage(progname):
|
||||||
print u"Removes DRM protection from Mobipocket, Amazon KF8, Amazon Print Replica and Amazon Topaz ebooks"
|
print u"Removes DRM protection from Mobipocket, Amazon KF8, Amazon Print Replica and Amazon Topaz ebooks"
|
||||||
print u"Usage:"
|
print u"Usage:"
|
||||||
print u" {0} [-k <kindle.k4i>] [-p <comma separated PIDs>] [-s <comma separated Kindle serial numbers>] [ -a <AmazonSecureStorage.xml|backup.ab> ] <infile> <outdir>".format(progname)
|
print u" {0} [-k <kindle.k4i>] [-p <comma separated PIDs>] [-s <comma separated Kindle serial numbers>] [ -a <AmazonSecureStorage.xml|backup.ab> ] <infile, infiles, or indir> <outdir>".format(progname)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main
|
# Main
|
||||||
|
@ -307,8 +309,7 @@ def cli_main():
|
||||||
usage(progname)
|
usage(progname)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
infile = args[0]
|
outdir = args.pop()
|
||||||
outdir = args[1]
|
|
||||||
kDatabaseFiles = []
|
kDatabaseFiles = []
|
||||||
androidFiles = []
|
androidFiles = []
|
||||||
serials = []
|
serials = []
|
||||||
|
@ -335,7 +336,21 @@ def cli_main():
|
||||||
# try with built in Kindle Info files if not on Linux
|
# try with built in Kindle Info files if not on Linux
|
||||||
k4 = not sys.platform.startswith('linux')
|
k4 = not sys.platform.startswith('linux')
|
||||||
|
|
||||||
return decryptBook(infile, outdir, kDatabaseFiles, androidFiles, serials, pids)
|
filenames = []
|
||||||
|
for filename in args:
|
||||||
|
if os.path.isdir(filename):
|
||||||
|
for file_extension in ['.azw', '.azw1', '.azw3', '.azw4', '.prc', '.mobi', '.pobi']:
|
||||||
|
filenames += glob.glob(os.path.join(filename, '*%s' % file_extension))
|
||||||
|
else:
|
||||||
|
# Assume a filename
|
||||||
|
filenames.append(filename)
|
||||||
|
|
||||||
|
for infile in filenames:
|
||||||
|
result = decryptBook(infile, outdir, kDatabaseFiles, androidFiles, serials, pids)
|
||||||
|
if result != 0:
|
||||||
|
print u'Error with %r' % infile
|
||||||
|
# return last result only
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user