Support cancelling
This commit is contained in:
parent
80fd7f844b
commit
5e840ae8bb
10
main.py
10
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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user