ChenyuRabbitLove commited on
Commit
eb076d0
1 Parent(s): 92e3c8d

feat: make load final player data automatically

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -18,9 +18,16 @@ seafoam = Seafoam()
18
 
19
 
20
  def get_player_info(player_backend_user_id):
21
- with open("latest_player_data.json", "r", encoding="utf-8") as file:
22
- player_info = json.load(file)
23
 
 
 
 
 
 
 
 
 
 
24
  if player_backend_user_id in player_info:
25
  return player_info[player_backend_user_id]
26
  else:
 
18
 
19
 
20
  def get_player_info(player_backend_user_id):
 
 
21
 
22
+ try:
23
+ with open("latest_player_data.json", "r", encoding="utf-8") as file:
24
+ player_info = json.load(file)
25
+ except FileNotFoundError:
26
+ logging.error("No player data found. Loading new player data.")
27
+ save_latest_player_data()
28
+ with open("latest_player_data.json", "r", encoding="utf-8") as file:
29
+ player_info = json.load(file)
30
+
31
  if player_backend_user_id in player_info:
32
  return player_info[player_backend_user_id]
33
  else: