瀏覽代碼

Catch json decoding errors

Colin Powell 1 年之前
父節點
當前提交
4fd8a5b9a5
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      vrobbler/apps/videogames/retroarch.py

+ 6 - 1
vrobbler/apps/videogames/retroarch.py

@@ -48,7 +48,12 @@ def load_game_data(directory_path: str, user_tz=None) -> dict:
 
         game_name = filename.split(".lrtl")[0].split(" (")[0]
         with open("".join([directory_path, filename])) as f:
-            games[game_name] = json.load(f)
+            try:
+                games[game_name] = json.load(f)
+            except json.JSONDecodeError:
+                logger.warn(
+                    f"Could not decode JSOn for {game_name} and file {filename}"
+                )
             # Convert runtime to seconds
             games[game_name]["runtime"] = convert_to_seconds(
                 games[game_name]["runtime"]