Skip to content

Commit

Permalink
allow user to set up extraction covers from AZW files
Browse files Browse the repository at this point in the history
  • Loading branch information
quiris11 committed Sep 23, 2014
1 parent 8fd0313 commit dab60c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions ExtractCoverThumbs.py
Expand Up @@ -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()
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion __main__.py
Expand Up @@ -35,11 +35,13 @@
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
docs = os.path.join(kindlepth, 'documents')

if __name__ == '__main__':
sys.exit(extract_cover_thumbs(args.verbose, args.overwrite, args.apnx,
kindlepth, docs))
kindlepth, docs, args.azw))

0 comments on commit dab60c6

Please sign in to comment.