Jelajahi Sumber

[bin] Fix wallpaper lookups

Colin Powell 2 tahun lalu
induk
melakukan
8a3da48a26
1 mengubah file dengan 9 tambahan dan 5 penghapusan
  1. 9 5
      bin/.bin/get_bing_potd.py

+ 9 - 5
bin/.bin/get_bing_potd.py

@@ -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 = today_img - yesterday_img < cutoff
+    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
+    except:
+        pass
 
     if not found_match:
         print(f"Bing image for {today} already exists, skipping download")