From dab60c6dda49f85521c957190ce74ad293554f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20B=C5=82aut?= Date: Tue, 23 Sep 2014 14:42:59 +0200 Subject: [PATCH] allow user to set up extraction covers from AZW files --- ExtractCoverThumbs.py | 12 +++++++++--- __main__.py | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ExtractCoverThumbs.py b/ExtractCoverThumbs.py index ab83247..62baf30 100755 --- a/ExtractCoverThumbs.py +++ b/ExtractCoverThumbs.py @@ -116,7 +116,8 @@ def generate_apnx_files(dir_list, docs, is_verbose, is_overwrite): apnx_builder.write_apnx(mobi_path, apnx_path) -def extract_cover_thumbs(is_verbose, is_overwrite, is_apnx, kindlepath, docs): +def extract_cover_thumbs(is_verbose, is_overwrite, is_apnx, kindlepath, docs, + is_azw): try: dir_list = os.listdir(docs) dir_list.sort() @@ -131,9 +132,14 @@ def extract_cover_thumbs(is_verbose, is_overwrite, is_apnx, kindlepath, docs): 'Probably not a Kindle Paperwhite/Touch device.') return 1 print("START of extracting cover thumbnails...") - print("NOTICE! AZW files are IGNORED!") + print("Notice! AZW files by default are ignored. " + "Use -z option to override.") + if is_azw: + extensions = ('.azw', '.azw3', '.mobi') + else: + extensions = ('.azw3', '.mobi') for f in dir_list: - if f.lower().endswith(('.azw3', '.mobi')): + if f.lower().endswith(extensions): fide = f.decode(sys.getfilesystemencoding()) mobi_path = os.path.join(docs, f) if is_verbose: diff --git a/__main__.py b/__main__.py index bfee3cb..e0ec907 100644 --- a/__main__.py +++ b/__main__.py @@ -35,6 +35,8 @@ action="store_true") parser.add_argument("-a", "--apnx", help="also generate APNX files", action="store_true") +parser.add_argument("-z", "--azw", help="also extract covers from AZW files", + action="store_true") args = parser.parse_args() kindlepth = args.kindle_directory @@ -42,4 +44,4 @@ if __name__ == '__main__': sys.exit(extract_cover_thumbs(args.verbose, args.overwrite, args.apnx, - kindlepth, docs)) + kindlepth, docs, args.azw))