diff --git a/main.py b/main.py index f949256..ce77271 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ import glob import os import hashlib +import time from PIL import Image, UnidentifiedImageError from imagehash import average_hash @@ -20,8 +21,8 @@ except KeyboardInterrupt: print('\nCancelled.') os._exit(0) -print('Sorting file list by size...') -filenames.sort(key=os.path.getsize, reverse=True) +print('Sorting file list by smallest size...') +filenames.sort(key=os.path.getsize, reverse=False) print('Deduplicating by md5 hash...') @@ -66,12 +67,17 @@ for filename in filenames: try: digest = get_image_hash(filename) or get_video_hash(filename) + except KeyboardInterrupt: + print('\nCancelled.') + os._exit(0) except BaseException as e: print() print('Exception', e.__class__.__name__, str(e), 'while hashing:') print(filename) continue + time.sleep(5) + if not digest: continue if digest in hashes: