From 2bbc32f54d510e297093b1fbde1e0773239159d6 Mon Sep 17 00:00:00 2001 From: 544146 Date: Wed, 13 Dec 2023 16:33:19 +0000 Subject: [PATCH] Add encoding and fix errors --- model/feetsaber.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/model/feetsaber.py b/model/feetsaber.py index 506af0db..8c29297b 100644 --- a/model/feetsaber.py +++ b/model/feetsaber.py @@ -165,7 +165,9 @@ class FSInfoDat: songFilename=json_dict['_songFilename'], coverImageFilename=json_dict['_coverImageFilename'], environmentName=json_dict['_environmentName'], - allDirectionsEnvironmentName=json_dict['_allDirectionsEnvironmentName'], + allDirectionsEnvironmentName=json_dict.get( + '_allDirectionsEnvironmentName', + ), songTimeOffset=json_dict['_songTimeOffset'], customData=custom_data, difficultyBeatmapSets=difficulty_beatmaps_list, @@ -363,7 +365,7 @@ class FSBeatMapFile: FSBeatMapFileBookmark( time=bm['_time'], name=bm['_name'], - color=bm['_color'], + color=bm.get('_color'), ) for bm in json_dict['_customData'].get('_bookmarks') or [] ], ) @@ -422,12 +424,12 @@ class FSBeatMapFile: events=events, notes=notes, obstacles=obstacles, - waypoints=json_dict['_waypoints'], + waypoints=json_dict.get('_waypoints'), ) @classmethod def from_json_file(cls, json_file: str) -> FSBeatMapFile: import json - with open(json_file) as f: + with open(json_file, encoding='utf-8') as f: json_dict = json.load(f) return cls.from_json_dict(json_dict)