From bc89624ad3606dccb659e9ca00f4183e3ff6f8bf Mon Sep 17 00:00:00 2001 From: qwewqa <198e559dbd446d973355f415bdfa34@gmail.com> Date: Sat, 26 Dec 2020 19:30:00 -0500 Subject: [PATCH] fix placeholder music data replacing existing music --- miyu_bot/commands/cogs/music.py | 3 ++- miyu_bot/commands/common/fuzzy_matching.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/miyu_bot/commands/cogs/music.py b/miyu_bot/commands/cogs/music.py index c0c27b6..be26289 100644 --- a/miyu_bot/commands/cogs/music.py +++ b/miyu_bot/commands/cogs/music.py @@ -21,7 +21,8 @@ class Music(commands.Cog): self.logger = logging.getLogger(__name__) self.music = FuzzyMap(lambda m: m.is_released) for m in asset_manager.music_master.values(): - self.music[f'{m.name} {m.special_unit_name}'] = m + if not self.music.has_exact(f'{m.name} {m.special_unit_name}'): + self.music[f'{m.name} {m.special_unit_name}'] = m difficulty_names = { 'expert': ChartDifficulty.Expert, diff --git a/miyu_bot/commands/common/fuzzy_matching.py b/miyu_bot/commands/common/fuzzy_matching.py index f051489..afe0bef 100644 --- a/miyu_bot/commands/common/fuzzy_matching.py +++ b/miyu_bot/commands/common/fuzzy_matching.py @@ -19,6 +19,9 @@ class FuzzyMap: def values(self): return FuzzyDictValuesView(self) + def has_exact(self, key): + return romanize(key) in self._values + def __delitem__(self, key): k = romanize(key) self._values.__delitem__(k)