update read script
This commit is contained in:
parent
cd9d8aed16
commit
99e60e6bbc
@ -1302,26 +1302,48 @@ class ImportJubeat(ImportBase):
|
|||||||
no_combine: bool,
|
no_combine: bool,
|
||||||
update: bool,
|
update: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
actual_version = {
|
if version in ['saucer', 'saucer-fulfill', 'prop', 'qubell', 'clan', 'festo']:
|
||||||
'saucer': VersionConstants.JUBEAT_SAUCER,
|
actual_version = {
|
||||||
'saucer-fulfill': VersionConstants.JUBEAT_SAUCER_FULFILL,
|
'saucer': VersionConstants.JUBEAT_SAUCER,
|
||||||
'prop': VersionConstants.JUBEAT_PROP,
|
'saucer-fulfill': VersionConstants.JUBEAT_SAUCER_FULFILL,
|
||||||
'qubell': VersionConstants.JUBEAT_QUBELL,
|
'prop': VersionConstants.JUBEAT_PROP,
|
||||||
'clan': VersionConstants.JUBEAT_CLAN,
|
'qubell': VersionConstants.JUBEAT_QUBELL,
|
||||||
'all': None, # Special case for importing metadata
|
'clan': VersionConstants.JUBEAT_CLAN,
|
||||||
}.get(version, -1)
|
'festo': VersionConstants.JUBEAT_FESTO,
|
||||||
|
}.get(version, -1)
|
||||||
|
elif version in ['omni-prop', 'omni-qubell', 'omni-clan', 'omni-festo']:
|
||||||
|
actual_version = {
|
||||||
|
'omni-prop': VersionConstants.JUBEAT_PROP,
|
||||||
|
'omni-qubell': VersionConstants.JUBEAT_QUBELL,
|
||||||
|
'omni-clan': VersionConstants.JUBEAT_CLAN,
|
||||||
|
'omni-festo': VersionConstants.JUBEAT_FESTO,
|
||||||
|
}.get(version, -1) + DBConstants.OMNIMIX_VERSION_BUMP
|
||||||
|
|
||||||
|
elif version == 'all':
|
||||||
|
actual_version = None
|
||||||
|
|
||||||
if actual_version in [
|
if actual_version in [
|
||||||
None,
|
None,
|
||||||
|
VersionConstants.JUBEAT_FESTO,
|
||||||
|
VersionConstants.JUBEAT_FESTO + DBConstants.OMNIMIX_VERSION_BUMP,
|
||||||
|
]:
|
||||||
|
# jubeat festo adds in separation of normal and hard mode scores.
|
||||||
|
# This adds a duplicate of each chart so that we show separated scores.
|
||||||
|
self.charts = [0, 1, 2, 3, 4, 5]
|
||||||
|
elif actual_version in [
|
||||||
VersionConstants.JUBEAT_SAUCER,
|
VersionConstants.JUBEAT_SAUCER,
|
||||||
VersionConstants.JUBEAT_SAUCER_FULFILL,
|
VersionConstants.JUBEAT_SAUCER_FULFILL,
|
||||||
VersionConstants.JUBEAT_PROP,
|
VersionConstants.JUBEAT_PROP,
|
||||||
VersionConstants.JUBEAT_QUBELL,
|
VersionConstants.JUBEAT_QUBELL,
|
||||||
VersionConstants.JUBEAT_CLAN,
|
VersionConstants.JUBEAT_CLAN,
|
||||||
|
VersionConstants.JUBEAT_PROP + DBConstants.OMNIMIX_VERSION_BUMP,
|
||||||
|
VersionConstants.JUBEAT_QUBELL + DBConstants.OMNIMIX_VERSION_BUMP,
|
||||||
|
VersionConstants.JUBEAT_CLAN + DBConstants.OMNIMIX_VERSION_BUMP,
|
||||||
]:
|
]:
|
||||||
self.charts = [0, 1, 2]
|
self.charts = [0, 1, 2]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Unsupported Jubeat version, expected one of the following: saucer, saucer-fulfill, prop, qubell, clan!")
|
raise Exception("Unsupported Jubeat version, expected one of the following: saucer, saucer-fulfill, prop, omni-prop, qubell, omni-qubell, clan, omni-clan, festo, omni-festo!")
|
||||||
|
|
||||||
super().__init__(config, GameConstants.JUBEAT, actual_version, no_combine, update)
|
super().__init__(config, GameConstants.JUBEAT, actual_version, no_combine, update)
|
||||||
|
|
||||||
@ -1367,15 +1389,23 @@ class ImportJubeat(ImportBase):
|
|||||||
}
|
}
|
||||||
if bpm_max > 0 and bpm_min < 0:
|
if bpm_max > 0 and bpm_min < 0:
|
||||||
bpm_min = bpm_max
|
bpm_min = bpm_max
|
||||||
difficulties = [
|
if music_entry.find('detail_level_bsc') is not None:
|
||||||
int(music_entry.find('level_bsc').text),
|
difficulties = [
|
||||||
int(music_entry.find('level_adv').text),
|
float(music_entry.find('detail_level_bsc').text),
|
||||||
int(music_entry.find('level_ext').text),
|
float(music_entry.find('detail_level_adv').text),
|
||||||
]
|
float(music_entry.find('detail_level_ext').text),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
difficulties = [
|
||||||
|
float(music_entry.find('level_bsc').text),
|
||||||
|
float(music_entry.find('level_adv').text),
|
||||||
|
float(music_entry.find('level_ext').text),
|
||||||
|
]
|
||||||
genre = "other"
|
genre = "other"
|
||||||
for possible_genre in music_entry.find('genre'):
|
if music_entry.find('genre') is not None: # Qubell extend music_info doesn't have this field
|
||||||
if int(possible_genre.text) != 0:
|
for possible_genre in music_entry.find('genre'):
|
||||||
genre = str(possible_genre.tag)
|
if int(possible_genre.text) != 0:
|
||||||
|
genre = str(possible_genre.tag)
|
||||||
|
|
||||||
songs.append({
|
songs.append({
|
||||||
'id': songid,
|
'id': songid,
|
||||||
@ -1399,6 +1429,7 @@ class ImportJubeat(ImportBase):
|
|||||||
VersionConstants.JUBEAT_PROP,
|
VersionConstants.JUBEAT_PROP,
|
||||||
VersionConstants.JUBEAT_QUBELL,
|
VersionConstants.JUBEAT_QUBELL,
|
||||||
VersionConstants.JUBEAT_CLAN,
|
VersionConstants.JUBEAT_CLAN,
|
||||||
|
VersionConstants.JUBEAT_FESTO,
|
||||||
}:
|
}:
|
||||||
for emblem_entry in root.find('emblem_list') or []:
|
for emblem_entry in root.find('emblem_list') or []:
|
||||||
print(emblem_entry)
|
print(emblem_entry)
|
||||||
@ -1447,15 +1478,15 @@ class ImportJubeat(ImportBase):
|
|||||||
'artist': song.artist,
|
'artist': song.artist,
|
||||||
'genre': song.genre,
|
'genre': song.genre,
|
||||||
'version': song.data.get_int('version'),
|
'version': song.data.get_int('version'),
|
||||||
'bpm_min': song.data.get_int('bpm_min'),
|
'bpm_min': song.data.get_float('bpm_min'),
|
||||||
'bpm_max': song.data.get_int('bpm_max'),
|
'bpm_max': song.data.get_float('bpm_max'),
|
||||||
'difficulty': {
|
'difficulty': {
|
||||||
'basic': 0,
|
'basic': 0.0,
|
||||||
'advanced': 0,
|
'advanced': 0.0,
|
||||||
'extreme': 0,
|
'extreme': 0.0,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
lut[song.id]['difficulty'][chart_map[song.chart]] = song.data.get_int('difficulty')
|
lut[song.id]['difficulty'][chart_map[song.chart]] = song.data.get_float('difficulty')
|
||||||
|
|
||||||
# Reassemble the data
|
# Reassemble the data
|
||||||
reassembled_songs = [val for _, val in lut.items()]
|
reassembled_songs = [val for _, val in lut.items()]
|
||||||
@ -1465,6 +1496,7 @@ class ImportJubeat(ImportBase):
|
|||||||
VersionConstants.JUBEAT_PROP,
|
VersionConstants.JUBEAT_PROP,
|
||||||
VersionConstants.JUBEAT_QUBELL,
|
VersionConstants.JUBEAT_QUBELL,
|
||||||
VersionConstants.JUBEAT_CLAN,
|
VersionConstants.JUBEAT_CLAN,
|
||||||
|
VersionConstants.JUBEAT_FESTO,
|
||||||
}:
|
}:
|
||||||
game = self.remote_game(server, token)
|
game = self.remote_game(server, token)
|
||||||
for item in game.get_items(self.game, self.version):
|
for item in game.get_items(self.game, self.version):
|
||||||
@ -1480,6 +1512,36 @@ class ImportJubeat(ImportBase):
|
|||||||
|
|
||||||
return reassembled_songs, emblems
|
return reassembled_songs, emblems
|
||||||
|
|
||||||
|
def __revivals(self, songid: int, chart: int) -> Optional[int]:
|
||||||
|
old_id = self.get_music_id_for_song(songid, chart)
|
||||||
|
if old_id is not None:
|
||||||
|
return old_id
|
||||||
|
|
||||||
|
# In qubell and clan omnimix, PPAP and Bonjour the world are placed
|
||||||
|
# at this arbitrary songid since they weren't assigned one originally
|
||||||
|
# In jubeat festo, these songs were given proper songids so we need to account for this
|
||||||
|
legacy_to_modern_map = {
|
||||||
|
71000001: 70000124, # PPAP
|
||||||
|
71000002: 70000154, # Bonjour the world
|
||||||
|
50000020: 80000037, # 千本桜 was removed and then revived in clan
|
||||||
|
60000063: 70000100, # Khamen break sdvx had the first id for prop(never released officially)
|
||||||
|
}
|
||||||
|
modern_to_legacy_map = {v: k for k, v in legacy_to_modern_map.items()}
|
||||||
|
|
||||||
|
legacy_songid = legacy_to_modern_map.get(songid)
|
||||||
|
if legacy_songid is not None:
|
||||||
|
old_id = self.get_music_id_for_song(legacy_songid, chart)
|
||||||
|
if old_id is not None:
|
||||||
|
return old_id
|
||||||
|
|
||||||
|
modern_songid = modern_to_legacy_map.get(songid)
|
||||||
|
if modern_songid is not None:
|
||||||
|
old_id = self.get_music_id_for_song(modern_songid, chart)
|
||||||
|
if old_id is not None:
|
||||||
|
return old_id
|
||||||
|
# Failed, so create a new one
|
||||||
|
return None
|
||||||
|
|
||||||
def import_music_db(self, songs: List[Dict[str, Any]]) -> None:
|
def import_music_db(self, songs: List[Dict[str, Any]]) -> None:
|
||||||
if self.version is None:
|
if self.version is None:
|
||||||
raise Exception('Can\'t import Jubeat database for \'all\' version!')
|
raise Exception('Can\'t import Jubeat database for \'all\' version!')
|
||||||
@ -1499,22 +1561,40 @@ class ImportJubeat(ImportBase):
|
|||||||
|
|
||||||
self.start_batch()
|
self.start_batch()
|
||||||
for chart in self.charts:
|
for chart in self.charts:
|
||||||
# First, try to find in the DB from another version
|
if(chart <= 2):
|
||||||
old_id = self.get_music_id_for_song(songid, chart)
|
# First, try to find in the DB from another version
|
||||||
if self.no_combine or old_id is None:
|
old_id = self.__revivals(songid, chart)
|
||||||
# Insert original
|
if self.no_combine or old_id is None:
|
||||||
print(f"New entry for {songid} chart {chart}")
|
# Insert original
|
||||||
next_id = self.get_next_music_id()
|
print(f"New entry for {songid} chart {chart}")
|
||||||
|
next_id = self.get_next_music_id()
|
||||||
|
else:
|
||||||
|
# Insert pointing at same ID so scores transfer
|
||||||
|
print(f"Reused entry for {songid} chart {chart}")
|
||||||
|
next_id = old_id
|
||||||
|
data = {
|
||||||
|
'difficulty': song['difficulty'][chart_map[chart]],
|
||||||
|
'bpm_min': song['bpm_min'],
|
||||||
|
'bpm_max': song['bpm_max'],
|
||||||
|
'version': song['version'],
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
# Insert pointing at same ID so scores transfer
|
# First, try to find in the DB from another version
|
||||||
print(f"Reused entry for {songid} chart {chart}")
|
old_id = self.__revivals(songid, chart)
|
||||||
next_id = old_id
|
if self.no_combine or old_id is None:
|
||||||
data = {
|
# Insert original
|
||||||
'difficulty': song['difficulty'][chart_map[chart]],
|
print(f"New entry for {songid} chart {chart}")
|
||||||
'bpm_min': song['bpm_min'],
|
next_id = self.get_next_music_id()
|
||||||
'bpm_max': song['bpm_max'],
|
else:
|
||||||
'version': song['version'],
|
# Insert pointing at same ID so scores transfer
|
||||||
}
|
print(f"Reused entry for {songid} chart {chart}")
|
||||||
|
next_id = old_id
|
||||||
|
data = {
|
||||||
|
'difficulty': song['difficulty'][chart_map[chart - 3]],
|
||||||
|
'bpm_min': song['bpm_min'],
|
||||||
|
'bpm_max': song['bpm_max'],
|
||||||
|
'version': song['version'],
|
||||||
|
}
|
||||||
self.insert_music_id_for_song(next_id, songid, chart, song['title'], song['artist'], song['genre'], data)
|
self.insert_music_id_for_song(next_id, songid, chart, song['title'], song['artist'], song['genre'], data)
|
||||||
self.finish_batch()
|
self.finish_batch()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user