1
0
mirror of synced 2024-11-24 06:20:12 +01:00

Add a few hacks to make sure existing installations who forget to re-import jubeat data won't break.

This commit is contained in:
Jennifer Taylor 2022-08-17 04:58:31 +00:00
parent b520cd9a2b
commit 529dc5ef15
4 changed files with 81 additions and 18 deletions

View File

@ -35,9 +35,38 @@ class CatalogObject(BaseObject):
} }
def __format_jubeat_song(self, song: Song) -> Dict[str, Any]: def __format_jubeat_song(self, song: Song) -> Dict[str, Any]:
# Map a default if the user hasn't imported the version DB. This is a nasty
# hack but we don't want to break existing installations.
defaultcategory = {
1: VersionConstants.JUBEAT,
2: VersionConstants.JUBEAT_RIPPLES,
3: VersionConstants.JUBEAT_KNIT,
4: VersionConstants.JUBEAT_COPIOUS,
5: VersionConstants.JUBEAT_SAUCER,
6: VersionConstants.JUBEAT_PROP,
7: VersionConstants.JUBEAT_QUBELL,
8: VersionConstants.JUBEAT_CLAN,
9: VersionConstants.JUBEAT_FESTO
}.get(int(song.id / 10000000), VersionConstants.JUBEAT)
# Map the category to the version numbers defined on BEMAPI.
categorymapping = {
VersionConstants.JUBEAT: '1',
VersionConstants.JUBEAT_RIPPLES: '2',
VersionConstants.JUBEAT_RIPPLES_APPEND: '2a',
VersionConstants.JUBEAT_KNIT: '3',
VersionConstants.JUBEAT_KNIT_APPEND: '3a',
VersionConstants.JUBEAT_COPIOUS: '4',
VersionConstants.JUBEAT_COPIOUS_APPEND: '4a',
VersionConstants.JUBEAT_SAUCER: '5',
VersionConstants.JUBEAT_SAUCER_FULFILL: '5a',
VersionConstants.JUBEAT_PROP: '6',
VersionConstants.JUBEAT_QUBELL: '7',
VersionConstants.JUBEAT_CLAN: '8',
VersionConstants.JUBEAT_FESTO: '9',
}
return { return {
'difficulty': song.data.get_int('difficulty'), 'difficulty': song.data.get_int('difficulty'),
'category': song.data.get_int('version'), 'category': categorymapping.get(song.data.get_int('version', defaultcategory), '1'),
'bpm_min': song.data.get_int('bpm_min'), 'bpm_min': song.data.get_int('bpm_min'),
'bpm_max': song.data.get_int('bpm_max'), 'bpm_max': song.data.get_int('bpm_max'),
} }

View File

@ -913,6 +913,33 @@ class GlobalMusicData(BaseGlobalData):
genre: Optional[str], genre: Optional[str],
data: Dict[str, Any], data: Dict[str, Any],
) -> Song: ) -> Song:
defaultcategory = {
1: VersionConstants.JUBEAT,
2: VersionConstants.JUBEAT_RIPPLES,
3: VersionConstants.JUBEAT_KNIT,
4: VersionConstants.JUBEAT_COPIOUS,
5: VersionConstants.JUBEAT_SAUCER,
6: VersionConstants.JUBEAT_PROP,
7: VersionConstants.JUBEAT_QUBELL,
8: VersionConstants.JUBEAT_CLAN,
9: VersionConstants.JUBEAT_FESTO
}.get(int(songid / 10000000), VersionConstants.JUBEAT)
# Map the category to the version numbers defined on BEMAPI.
categorymapping = {
'1': VersionConstants.JUBEAT,
'2': VersionConstants.JUBEAT_RIPPLES,
'2a': VersionConstants.JUBEAT_RIPPLES_APPEND,
'3': VersionConstants.JUBEAT_KNIT,
'3a': VersionConstants.JUBEAT_KNIT_APPEND,
'4': VersionConstants.JUBEAT_COPIOUS,
'4a': VersionConstants.JUBEAT_COPIOUS_APPEND,
'5': VersionConstants.JUBEAT_SAUCER,
'5a': VersionConstants.JUBEAT_SAUCER_FULFILL,
'6': VersionConstants.JUBEAT_PROP,
'7': VersionConstants.JUBEAT_QUBELL,
'8': VersionConstants.JUBEAT_CLAN,
'9': VersionConstants.JUBEAT_FESTO,
}
return Song( return Song(
game=GameConstants.JUBEAT, game=GameConstants.JUBEAT,
version=version, version=version,
@ -925,7 +952,7 @@ class GlobalMusicData(BaseGlobalData):
'bpm_min': int(data['bpm_min']), 'bpm_min': int(data['bpm_min']),
'bpm_max': int(data['bpm_max']), 'bpm_max': int(data['bpm_max']),
'difficulty': int(data['difficulty']), 'difficulty': int(data['difficulty']),
'version': int(data.get('category', int(songid / 10000000))), 'version': categorymapping.get(data.get('category', '0'), defaultcategory),
}, },
) )

View File

@ -194,7 +194,7 @@ def viewtopscores(musicid: int) -> Response:
artist = details.artist artist = details.artist
genre = details.genre genre = details.genre
if category < version: if category < version:
category = version; category = version
if difficulties[chart] == 0.0: if difficulties[chart] == 0.0:
difficulties[chart] = details.data.get_float('difficulty', 13) difficulties[chart] = details.data.get_float('difficulty', 13)
if difficulties[chart] >= 13.0: if difficulties[chart] >= 13.0:

View File

@ -91,21 +91,28 @@ class JubeatFrontend(FrontendBase):
formatted_song['bpm_min'] = song.data.get_int('bpm_min', 120) formatted_song['bpm_min'] = song.data.get_int('bpm_min', 120)
formatted_song['bpm_max'] = song.data.get_int('bpm_max', 120) formatted_song['bpm_max'] = song.data.get_int('bpm_max', 120)
formatted_song['difficulties'] = difficulties formatted_song['difficulties'] = difficulties
formatted_song['version'] = { version = song.data.get_int('version', 0)
VersionConstants.JUBEAT: 1, if version == 0:
VersionConstants.JUBEAT_RIPPLES: 2, # The default here is a nasty hack for installations that existed prior to importing
VersionConstants.JUBEAT_RIPPLES_APPEND: 2, # version using read.py. This ensures that not importing again won't break existing
VersionConstants.JUBEAT_KNIT: 3, # installations.
VersionConstants.JUBEAT_KNIT_APPEND: 3, formatted_song['version'] = int(song.id / 10000000)
VersionConstants.JUBEAT_COPIOUS: 4, else:
VersionConstants.JUBEAT_COPIOUS_APPEND: 4, formatted_song['version'] = {
VersionConstants.JUBEAT_SAUCER: 5, VersionConstants.JUBEAT: 1,
VersionConstants.JUBEAT_SAUCER_FULFILL: 5, VersionConstants.JUBEAT_RIPPLES: 2,
VersionConstants.JUBEAT_PROP: 6, VersionConstants.JUBEAT_RIPPLES_APPEND: 2,
VersionConstants.JUBEAT_QUBELL: 7, VersionConstants.JUBEAT_KNIT: 3,
VersionConstants.JUBEAT_CLAN: 8, VersionConstants.JUBEAT_KNIT_APPEND: 3,
VersionConstants.JUBEAT_FESTO: 9, VersionConstants.JUBEAT_COPIOUS: 4,
}.get(song.data.get_int('version', 1), 1) VersionConstants.JUBEAT_COPIOUS_APPEND: 4,
VersionConstants.JUBEAT_SAUCER: 5,
VersionConstants.JUBEAT_SAUCER_FULFILL: 5,
VersionConstants.JUBEAT_PROP: 6,
VersionConstants.JUBEAT_QUBELL: 7,
VersionConstants.JUBEAT_CLAN: 8,
VersionConstants.JUBEAT_FESTO: 9,
}[version]
return formatted_song return formatted_song
def merge_song(self, existing: Dict[str, Any], new: Song) -> Dict[str, Any]: def merge_song(self, existing: Dict[str, Any], new: Song) -> Dict[str, Any]: