瀏覽代碼

[bin] Fix wallpaper lookups

Colin Powell 2 年之前
父節點
當前提交
8a3da48a26
共有 1 個文件被更改,包括 9 次插入5 次删除
  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")