Browse Source

Catch json decoding errors

Colin Powell 1 năm trước cách đây
mục cha
commit
4fd8a5b9a5
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  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"]