From 6de1cd7e6d417a5dba9b398259e08f8f043a8f0b Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 12 Nov 2022 22:56:06 +0000 Subject: [PATCH] Fix key error in merging jubeat songs that don't have a set music rate. --- bemani/data/api/music.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bemani/data/api/music.py b/bemani/data/api/music.py index ea79b7a..5c284d2 100644 --- a/bemani/data/api/music.py +++ b/bemani/data/api/music.py @@ -401,6 +401,10 @@ class GlobalMusicData(BaseGlobalData): def __merge_jubeat_score( self, version: int, oldscore: Score, newscore: Score ) -> Score: + rate = self.__max( + oldscore.data.get("music_rate", -1), newscore.data.get("music_rate", -1) + ) + return Score( -1, oldscore.id, @@ -419,9 +423,8 @@ class GlobalMusicData(BaseGlobalData): else newscore.data.get("ghost"), "combo": self.__max(oldscore.data["combo"], newscore.data["combo"]), "medal": self.__max(oldscore.data["medal"], newscore.data["medal"]), - "music_rate": self.__max( - oldscore.data["music_rate"], newscore.data["music_rate"] - ), + # Conditionally include this if we have any info for it. + **({"music_rate": rate} if rate >= 0 else {}), }, )