[bin] Fix wallpaper lookups

This commit is contained in:
2023-03-15 16:38:05 -04:00
parent cc2fe67446
commit 8a3da48a26

View File

@ -17,11 +17,15 @@ target_path = f"{home}/var/media/backgrounds/bing/{today}.jpg"
# If the file for today already exists, just exit
if os.path.isfile(target_path):
yesterday_img = imagehash.average_hash(Image.open(check_path))
today_img = imagehash.average_hash(Image.open(target_path))
cutoff = 5 # maximum bits that could be different between the hashes.
found_match = False
try:
yesterday_img = imagehash.average_hash(Image.open(check_path))
today_img = imagehash.average_hash(Image.open(target_path))
cutoff = 5 # maximum bits that could be different between the hashes.
found_match = today_img - yesterday_img < cutoff
found_match = today_img - yesterday_img < cutoff
except:
pass
if not found_match:
print(f"Bing image for {today} already exists, skipping download")