Fix missing self.version->self.music_version renames, fix formatting, lint issues.
This commit is contained in:
parent
9a7d0ccdb9
commit
b93b8aed4f
@ -341,7 +341,9 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base):
|
|||||||
) -> None:
|
) -> None:
|
||||||
# Generate scorecard
|
# Generate scorecard
|
||||||
profile = self.get_profile(userid)
|
profile = self.get_profile(userid)
|
||||||
song = self.data.local.music.get_song(self.game, self.music_version, songid, chart)
|
song = self.data.local.music.get_song(
|
||||||
|
self.game, self.music_version, songid, chart
|
||||||
|
)
|
||||||
|
|
||||||
card_medal = {
|
card_medal = {
|
||||||
self.PLAY_MEDAL_CIRCLE_FAILED: "Failed",
|
self.PLAY_MEDAL_CIRCLE_FAILED: "Failed",
|
||||||
|
@ -328,7 +328,7 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
|
|||||||
|
|
||||||
# Top 500 Popular music
|
# Top 500 Popular music
|
||||||
for songid, _plays in self.data.local.music.get_hit_chart(
|
for songid, _plays in self.data.local.music.get_hit_chart(
|
||||||
self.game, self.version, 500
|
self.game, self.music_version, 500
|
||||||
):
|
):
|
||||||
popular_music = Node.void("popular_music")
|
popular_music = Node.void("popular_music")
|
||||||
root.add_child(popular_music)
|
root.add_child(popular_music)
|
||||||
@ -575,7 +575,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
|
|||||||
return root
|
return root
|
||||||
rivalid = links[no].other_userid
|
rivalid = links[no].other_userid
|
||||||
rivalprofile = profiles[rivalid]
|
rivalprofile = profiles[rivalid]
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, rivalid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, rivalid
|
||||||
|
)
|
||||||
|
|
||||||
# First, output general profile info.
|
# First, output general profile info.
|
||||||
friend = Node.void("friend")
|
friend = Node.void("friend")
|
||||||
@ -673,7 +675,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
|
|||||||
return Node.void("player24")
|
return Node.void("player24")
|
||||||
|
|
||||||
root = Node.void("player24")
|
root = Node.void("player24")
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
# Skip any scores for chart types we don't support
|
# Skip any scores for chart types we don't support
|
||||||
if score.chart not in [
|
if score.chart not in [
|
||||||
@ -829,7 +833,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
|
|||||||
root.add_child(Node.s8("result", 1))
|
root.add_child(Node.s8("result", 1))
|
||||||
|
|
||||||
# Scores
|
# Scores
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
# Skip any scores for chart types we don't support
|
# Skip any scores for chart types we don't support
|
||||||
if score.chart not in [
|
if score.chart not in [
|
||||||
@ -1036,13 +1042,13 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
|
|||||||
last_played = [
|
last_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_last_played(
|
for x in self.data.local.music.get_last_played(
|
||||||
self.game, self.version, userid, 10
|
self.game, self.music_version, userid, 10
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
most_played = [
|
most_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_most_played(
|
for x in self.data.local.music.get_most_played(
|
||||||
self.game, self.version, userid, 20
|
self.game, self.music_version, userid, 20
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
while len(last_played) < 10:
|
while len(last_played) < 10:
|
||||||
@ -1157,7 +1163,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
|
|||||||
if game_config.get_bool("force_unlock_songs"):
|
if game_config.get_bool("force_unlock_songs"):
|
||||||
songs = {
|
songs = {
|
||||||
song.id
|
song.id
|
||||||
for song in self.data.local.music.get_all_songs(self.game, self.version)
|
for song in self.data.local.music.get_all_songs(
|
||||||
|
self.game, self.music_version
|
||||||
|
)
|
||||||
}
|
}
|
||||||
for song in songs:
|
for song in songs:
|
||||||
item = Node.void("item")
|
item = Node.void("item")
|
||||||
|
@ -210,7 +210,7 @@ class PopnMusicEclale(PopnMusicBase):
|
|||||||
|
|
||||||
# Output the hit chart
|
# Output the hit chart
|
||||||
for songid, _plays in self.data.local.music.get_hit_chart(
|
for songid, _plays in self.data.local.music.get_hit_chart(
|
||||||
self.game, self.version, 500
|
self.game, self.music_version, 500
|
||||||
):
|
):
|
||||||
popular_music = Node.void("popular_music")
|
popular_music = Node.void("popular_music")
|
||||||
root.add_child(popular_music)
|
root.add_child(popular_music)
|
||||||
@ -360,7 +360,9 @@ class PopnMusicEclale(PopnMusicBase):
|
|||||||
|
|
||||||
userid = self.data.remote.user.from_refid(self.game, self.version, refid)
|
userid = self.data.remote.user.from_refid(self.game, self.version, refid)
|
||||||
if userid is not None:
|
if userid is not None:
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
scores = []
|
scores = []
|
||||||
|
|
||||||
@ -451,7 +453,9 @@ class PopnMusicEclale(PopnMusicBase):
|
|||||||
return root
|
return root
|
||||||
rivalid = links[no].other_userid
|
rivalid = links[no].other_userid
|
||||||
rivalprofile = profiles[rivalid]
|
rivalprofile = profiles[rivalid]
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, rivalid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, rivalid
|
||||||
|
)
|
||||||
|
|
||||||
# First, output general profile info.
|
# First, output general profile info.
|
||||||
friend = Node.void("friend")
|
friend = Node.void("friend")
|
||||||
@ -573,7 +577,9 @@ class PopnMusicEclale(PopnMusicBase):
|
|||||||
root.add_child(Node.s8("result", 1))
|
root.add_child(Node.s8("result", 1))
|
||||||
|
|
||||||
# Scores
|
# Scores
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
# Skip any scores for chart types we don't support
|
# Skip any scores for chart types we don't support
|
||||||
if score.chart not in [
|
if score.chart not in [
|
||||||
@ -684,13 +690,13 @@ class PopnMusicEclale(PopnMusicBase):
|
|||||||
last_played = [
|
last_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_last_played(
|
for x in self.data.local.music.get_last_played(
|
||||||
self.game, self.version, userid, 5
|
self.game, self.music_version, userid, 5
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
most_played = [
|
most_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_most_played(
|
for x in self.data.local.music.get_most_played(
|
||||||
self.game, self.version, userid, 10
|
self.game, self.music_version, userid, 10
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
while len(last_played) < 5:
|
while len(last_played) < 5:
|
||||||
@ -794,7 +800,9 @@ class PopnMusicEclale(PopnMusicBase):
|
|||||||
if game_config.get_bool("force_unlock_songs"):
|
if game_config.get_bool("force_unlock_songs"):
|
||||||
songs = {
|
songs = {
|
||||||
song.id
|
song.id
|
||||||
for song in self.data.local.music.get_all_songs(self.game, self.version)
|
for song in self.data.local.music.get_all_songs(
|
||||||
|
self.game, self.music_version
|
||||||
|
)
|
||||||
}
|
}
|
||||||
for song in songs:
|
for song in songs:
|
||||||
item = Node.void("item")
|
item = Node.void("item")
|
||||||
|
@ -204,13 +204,13 @@ class PopnMusicFantasia(PopnMusicBase):
|
|||||||
last_played = [
|
last_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_last_played(
|
for x in self.data.local.music.get_last_played(
|
||||||
self.game, self.version, userid, 3
|
self.game, self.music_version, userid, 3
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
most_played = [
|
most_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_most_played(
|
for x in self.data.local.music.get_most_played(
|
||||||
self.game, self.version, userid, 20
|
self.game, self.music_version, userid, 20
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
while len(last_played) < 3:
|
while len(last_played) < 3:
|
||||||
@ -222,7 +222,9 @@ class PopnMusicFantasia(PopnMusicBase):
|
|||||||
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
||||||
clear_medal_sub = [0] * self.GAME_MAX_MUSIC_ID
|
clear_medal_sub = [0] * self.GAME_MAX_MUSIC_ID
|
||||||
|
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
if score.id > self.GAME_MAX_MUSIC_ID:
|
if score.id > self.GAME_MAX_MUSIC_ID:
|
||||||
continue
|
continue
|
||||||
@ -329,7 +331,9 @@ class PopnMusicFantasia(PopnMusicBase):
|
|||||||
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
||||||
hiscore_array = [0] * int((((self.GAME_MAX_MUSIC_ID * 4) * 17) + 7) / 8)
|
hiscore_array = [0] * int((((self.GAME_MAX_MUSIC_ID * 4) * 17) + 7) / 8)
|
||||||
|
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
if score.id > self.GAME_MAX_MUSIC_ID:
|
if score.id > self.GAME_MAX_MUSIC_ID:
|
||||||
continue
|
continue
|
||||||
@ -643,7 +647,9 @@ class PopnMusicFantasia(PopnMusicBase):
|
|||||||
for rival in links[:2]:
|
for rival in links[:2]:
|
||||||
rivalid = rival.other_userid
|
rivalid = rival.other_userid
|
||||||
rivalprofile = profiles[rivalid]
|
rivalprofile = profiles[rivalid]
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, rivalid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, rivalid
|
||||||
|
)
|
||||||
|
|
||||||
# First, output general profile info.
|
# First, output general profile info.
|
||||||
friend = Node.void("friend")
|
friend = Node.void("friend")
|
||||||
|
@ -334,7 +334,9 @@ class PopnMusicLapistoria(PopnMusicBase):
|
|||||||
return root
|
return root
|
||||||
rivalid = links[no].other_userid
|
rivalid = links[no].other_userid
|
||||||
rivalprofile = profiles[rivalid]
|
rivalprofile = profiles[rivalid]
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, rivalid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, rivalid
|
||||||
|
)
|
||||||
achievements = self.data.local.user.get_achievements(
|
achievements = self.data.local.user.get_achievements(
|
||||||
self.game, self.version, rivalid
|
self.game, self.version, rivalid
|
||||||
)
|
)
|
||||||
@ -658,13 +660,13 @@ class PopnMusicLapistoria(PopnMusicBase):
|
|||||||
last_played = [
|
last_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_last_played(
|
for x in self.data.local.music.get_last_played(
|
||||||
self.game, self.version, userid, 5
|
self.game, self.music_version, userid, 5
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
most_played = [
|
most_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_most_played(
|
for x in self.data.local.music.get_most_played(
|
||||||
self.game, self.version, userid, 10
|
self.game, self.music_version, userid, 10
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
while len(last_played) < 5:
|
while len(last_played) < 5:
|
||||||
@ -675,7 +677,9 @@ class PopnMusicLapistoria(PopnMusicBase):
|
|||||||
account.add_child(Node.s16_array("my_best", most_played))
|
account.add_child(Node.s16_array("my_best", most_played))
|
||||||
account.add_child(Node.s16_array("latest_music", last_played))
|
account.add_child(Node.s16_array("latest_music", last_played))
|
||||||
|
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
# Skip any scores for chart types we don't support
|
# Skip any scores for chart types we don't support
|
||||||
if score.chart not in [
|
if score.chart not in [
|
||||||
@ -822,7 +826,9 @@ class PopnMusicLapistoria(PopnMusicBase):
|
|||||||
if game_config.get_bool("force_unlock_songs"):
|
if game_config.get_bool("force_unlock_songs"):
|
||||||
songs = {
|
songs = {
|
||||||
song.id
|
song.id
|
||||||
for song in self.data.local.music.get_all_songs(self.game, self.version)
|
for song in self.data.local.music.get_all_songs(
|
||||||
|
self.game, self.music_version
|
||||||
|
)
|
||||||
}
|
}
|
||||||
for song in songs:
|
for song in songs:
|
||||||
item = Node.void("item")
|
item = Node.void("item")
|
||||||
@ -1082,7 +1088,9 @@ class PopnMusicLapistoria(PopnMusicBase):
|
|||||||
root.add_child(Node.s32("option", profile.get_int("option", 0)))
|
root.add_child(Node.s32("option", profile.get_int("option", 0)))
|
||||||
root.add_child(Node.s8("result", 1))
|
root.add_child(Node.s8("result", 1))
|
||||||
|
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
if score.id > self.GAME_MAX_MUSIC_ID:
|
if score.id > self.GAME_MAX_MUSIC_ID:
|
||||||
continue
|
continue
|
||||||
|
@ -186,13 +186,13 @@ class PopnMusicSunnyPark(PopnMusicBase):
|
|||||||
last_played = [
|
last_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_last_played(
|
for x in self.data.local.music.get_last_played(
|
||||||
self.game, self.version, userid, 3
|
self.game, self.music_version, userid, 3
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
most_played = [
|
most_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_most_played(
|
for x in self.data.local.music.get_most_played(
|
||||||
self.game, self.version, userid, 20
|
self.game, self.music_version, userid, 20
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
while len(last_played) < 3:
|
while len(last_played) < 3:
|
||||||
@ -204,7 +204,9 @@ class PopnMusicSunnyPark(PopnMusicBase):
|
|||||||
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
||||||
clear_medal_sub = [0] * self.GAME_MAX_MUSIC_ID
|
clear_medal_sub = [0] * self.GAME_MAX_MUSIC_ID
|
||||||
|
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
if score.id > self.GAME_MAX_MUSIC_ID:
|
if score.id > self.GAME_MAX_MUSIC_ID:
|
||||||
continue
|
continue
|
||||||
@ -463,7 +465,9 @@ class PopnMusicSunnyPark(PopnMusicBase):
|
|||||||
|
|
||||||
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
clear_medal = [0] * self.GAME_MAX_MUSIC_ID
|
||||||
|
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
if score.id > self.GAME_MAX_MUSIC_ID:
|
if score.id > self.GAME_MAX_MUSIC_ID:
|
||||||
continue
|
continue
|
||||||
@ -815,7 +819,9 @@ class PopnMusicSunnyPark(PopnMusicBase):
|
|||||||
for rival in links[:2]:
|
for rival in links[:2]:
|
||||||
rivalid = rival.other_userid
|
rivalid = rival.other_userid
|
||||||
rivalprofile = profiles[rivalid]
|
rivalprofile = profiles[rivalid]
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, rivalid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, rivalid
|
||||||
|
)
|
||||||
|
|
||||||
# First, output general profile info.
|
# First, output general profile info.
|
||||||
friend = Node.void("friend")
|
friend = Node.void("friend")
|
||||||
|
@ -227,7 +227,9 @@ class PopnMusicTuneStreet(PopnMusicBase):
|
|||||||
|
|
||||||
# Format Scores
|
# Format Scores
|
||||||
hiscore_array = [0] * int((((self.GAME_MAX_MUSIC_ID * 7) * 17) + 7) / 8)
|
hiscore_array = [0] * int((((self.GAME_MAX_MUSIC_ID * 7) * 17) + 7) / 8)
|
||||||
scores = self.data.remote.music.get_scores(self.game, self.version, userid)
|
scores = self.data.remote.music.get_scores(
|
||||||
|
self.game, self.music_version, userid
|
||||||
|
)
|
||||||
for score in scores:
|
for score in scores:
|
||||||
if score.id > self.GAME_MAX_MUSIC_ID:
|
if score.id > self.GAME_MAX_MUSIC_ID:
|
||||||
continue
|
continue
|
||||||
@ -284,7 +286,7 @@ class PopnMusicTuneStreet(PopnMusicBase):
|
|||||||
most_played = [
|
most_played = [
|
||||||
x[0]
|
x[0]
|
||||||
for x in self.data.local.music.get_most_played(
|
for x in self.data.local.music.get_most_played(
|
||||||
self.game, self.version, userid, 20
|
self.game, self.music_version, userid, 20
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
while len(most_played) < 20:
|
while len(most_played) < 20:
|
||||||
|
@ -186,20 +186,20 @@ def viewtopscores(musicid: int) -> Response:
|
|||||||
difficulties = [0, 0, 0, 0]
|
difficulties = [0, 0, 0, 0]
|
||||||
|
|
||||||
for version in versions:
|
for version in versions:
|
||||||
for omniadd in [0, DBConstants.OMNIMIX_VERSION_BUMP]:
|
for omniadd in [0, DBConstants.OMNIMIX_VERSION_BUMP]:
|
||||||
for chart in [0, 1, 2, 3]:
|
for chart in [0, 1, 2, 3]:
|
||||||
details = g.data.local.music.get_song(
|
details = g.data.local.music.get_song(
|
||||||
GameConstants.POPN_MUSIC, version + omniadd, musicid, chart
|
GameConstants.POPN_MUSIC, version + omniadd, musicid, chart
|
||||||
)
|
)
|
||||||
if details is not None:
|
if details is not None:
|
||||||
if name is None:
|
if name is None:
|
||||||
name = details.name
|
name = details.name
|
||||||
if artist is None:
|
if artist is None:
|
||||||
artist = details.artist
|
artist = details.artist
|
||||||
if genre is None:
|
if genre is None:
|
||||||
genre = details.genre
|
genre = details.genre
|
||||||
if difficulties[chart] == 0:
|
if difficulties[chart] == 0:
|
||||||
difficulties[chart] = details.data.get_int("difficulty")
|
difficulties[chart] = details.data.get_int("difficulty")
|
||||||
|
|
||||||
if name is None:
|
if name is None:
|
||||||
# Not a real song!
|
# Not a real song!
|
||||||
|
@ -398,9 +398,12 @@ class ImportPopn(ImportBase):
|
|||||||
"24": VersionConstants.POPN_MUSIC_USANEKO,
|
"24": VersionConstants.POPN_MUSIC_USANEKO,
|
||||||
"25": VersionConstants.POPN_MUSIC_PEACE,
|
"25": VersionConstants.POPN_MUSIC_PEACE,
|
||||||
"26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES,
|
"26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES,
|
||||||
"omni-24": VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP, #Omnimix v2 only works for 24 - 26
|
"omni-24": VersionConstants.POPN_MUSIC_USANEKO
|
||||||
"omni-25": VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP ,
|
+ DBConstants.OMNIMIX_VERSION_BUMP, # Omnimix v2 only works for 24 - 26
|
||||||
"omni-26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + DBConstants.OMNIMIX_VERSION_BUMP,
|
"omni-25": VersionConstants.POPN_MUSIC_PEACE
|
||||||
|
+ DBConstants.OMNIMIX_VERSION_BUMP,
|
||||||
|
"omni-26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES
|
||||||
|
+ DBConstants.OMNIMIX_VERSION_BUMP,
|
||||||
}.get(version, -1)
|
}.get(version, -1)
|
||||||
|
|
||||||
if actual_version == VersionConstants.POPN_MUSIC_TUNE_STREET:
|
if actual_version == VersionConstants.POPN_MUSIC_TUNE_STREET:
|
||||||
@ -419,85 +422,114 @@ class ImportPopn(ImportBase):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
config, GameConstants.POPN_MUSIC, actual_version, no_combine, update
|
config, GameConstants.POPN_MUSIC, actual_version, no_combine, update
|
||||||
)
|
)
|
||||||
|
|
||||||
def scrape_xml(self, xmlfile: str, songs: List[Dict[str, Any]] = []) -> List[Dict[str, Any]]:
|
def scrape_xml(
|
||||||
|
self, xmlfile: Path, songs: List[Dict[str, Any]] = []
|
||||||
with open(xmlfile, 'rb') as xmlhandle:
|
) -> List[Dict[str, Any]]:
|
||||||
xmldata = xmlhandle.read().decode('shift_jisx0213')
|
with open(xmlfile, "rb") as xmlhandle:
|
||||||
|
xmldata = xmlhandle.read().decode("shift_jisx0213")
|
||||||
root = ET.fromstring(xmldata)
|
root = ET.fromstring(xmldata)
|
||||||
|
|
||||||
for music_entry in root.findall('music'):
|
for music_entry in root.findall("music"):
|
||||||
difficulties = [0, 0, 0, 0, 0, 0]
|
difficulties = [0, 0, 0, 0, 0, 0]
|
||||||
filenames = ['', '', '', '', '', '']
|
filenames = ["", "", "", "", "", ""]
|
||||||
diff_map = {
|
diff_map = {
|
||||||
'ep': 0,
|
"ep": 0,
|
||||||
'np': 1,
|
"np": 1,
|
||||||
'hp': 2,
|
"hp": 2,
|
||||||
'op': 3,
|
"op": 3,
|
||||||
'bp_n': 4,
|
"bp_n": 4,
|
||||||
'bp_h': 5,
|
"bp_h": 5,
|
||||||
}
|
}
|
||||||
charts = music_entry.find('charts')
|
charts = music_entry.find("charts")
|
||||||
if charts is not None:
|
if charts is not None:
|
||||||
for chart in charts.findall('chart'):
|
for chart in charts.findall("chart"):
|
||||||
chart_idx = diff_map.get(chart.attrib['idx'])
|
chart_idx = diff_map.get(chart.attrib["idx"])
|
||||||
if chart.find('diff') is not None:
|
if chart.find("diff") is not None:
|
||||||
difficulties[chart_idx] = int(chart.find('diff').text)
|
difficulties[chart_idx] = int(chart.find("diff").text)
|
||||||
filenames[chart_idx] = f'{chart.find("folder").text}/{chart.find("filename").text}'
|
filenames[
|
||||||
|
chart_idx
|
||||||
|
] = f'{chart.find("folder").text}/{chart.find("filename").text}'
|
||||||
songinfo: Dict
|
songinfo: Dict
|
||||||
# Check if song metadata is in this entry
|
# Check if song metadata is in this entry
|
||||||
if music_entry.find('fw_title') is not None:
|
if music_entry.find("fw_title") is not None:
|
||||||
songinfo = {
|
songinfo = {
|
||||||
'id': int(music_entry.attrib['id']),
|
"id": int(music_entry.attrib["id"]),
|
||||||
'title': music_entry.find('fw_title').text,
|
"title": music_entry.find("fw_title").text,
|
||||||
'artist': music_entry.find('fw_artist').text,
|
"artist": music_entry.find("fw_artist").text,
|
||||||
'genre': music_entry.find('fw_genre').text,
|
"genre": music_entry.find("fw_genre").text,
|
||||||
'comment': music_entry.find('genre').text,
|
"comment": music_entry.find("genre").text,
|
||||||
'title_en': music_entry.find('title').text,
|
"title_en": music_entry.find("title").text,
|
||||||
'artist_en': music_entry.find('artist').text,
|
"artist_en": music_entry.find("artist").text,
|
||||||
'long_genre': '',
|
"long_genre": "",
|
||||||
'folder': music_entry.find('folder').text,
|
"folder": music_entry.find("folder").text,
|
||||||
'difficulty': {
|
"difficulty": {
|
||||||
'standard': {
|
"standard": {
|
||||||
'easy': difficulties[0],
|
"easy": difficulties[0],
|
||||||
'normal': difficulties[1],
|
"normal": difficulties[1],
|
||||||
'hyper': difficulties[2],
|
"hyper": difficulties[2],
|
||||||
'ex': difficulties[3],
|
"ex": difficulties[3],
|
||||||
|
},
|
||||||
|
"battle": {
|
||||||
|
"normal": difficulties[4],
|
||||||
|
"hyper": difficulties[5],
|
||||||
},
|
},
|
||||||
'battle': {
|
|
||||||
'normal': difficulties[4],
|
|
||||||
'hyper': difficulties[5],
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'file': {
|
"file": {
|
||||||
'standard': {
|
"standard": {
|
||||||
'easy': filenames[0],
|
"easy": filenames[0],
|
||||||
'normal': filenames[1],
|
"normal": filenames[1],
|
||||||
'hyper': filenames[2],
|
"hyper": filenames[2],
|
||||||
'ex': filenames[3],
|
"ex": filenames[3],
|
||||||
},
|
},
|
||||||
'battle': {
|
"battle": {
|
||||||
'normal': filenames[4],
|
"normal": filenames[4],
|
||||||
'hyper': filenames[5],
|
"hyper": filenames[5],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
# It's not here so find the entry at the current song id
|
# It's not here so find the entry at the current song id
|
||||||
else:
|
else:
|
||||||
for song in songs:
|
for song in songs:
|
||||||
if song['id'] == int(music_entry.attrib['id']):
|
if song["id"] == int(music_entry.attrib["id"]):
|
||||||
if difficulties is not None:
|
if difficulties is not None:
|
||||||
for diff, i in zip(['easy', 'normal', 'hyper', 'ex'], range(4)):
|
for diff, i in zip(
|
||||||
song['difficulty']['standard'][diff] = difficulties[i] if difficulties[i] else song['difficulty']['standard'][diff]
|
["easy", "normal", "hyper", "ex"], range(4)
|
||||||
song['file']['standard'][diff] = filenames[i] if filenames[i] else song['file']['standard'][diff]
|
):
|
||||||
|
song["difficulty"]["standard"][diff] = (
|
||||||
|
difficulties[i]
|
||||||
|
if difficulties[i]
|
||||||
|
else song["difficulty"]["standard"][diff]
|
||||||
|
)
|
||||||
|
song["file"]["standard"][diff] = (
|
||||||
|
filenames[i]
|
||||||
|
if filenames[i]
|
||||||
|
else song["file"]["standard"][diff]
|
||||||
|
)
|
||||||
|
|
||||||
song['difficulty']['battle']['normal'] = difficulties[4] if difficulties[4] else song['difficulty']['battle']['normal']
|
song["difficulty"]["battle"]["normal"] = (
|
||||||
song['difficulty']['battle']['hyper'] = difficulties[5] if difficulties[5] else song['difficulty']['battle']['hyper']
|
difficulties[4]
|
||||||
song['file']['battle']['normal'] = filenames[4] if filenames[4] else song['file']['battle']['normal']
|
if difficulties[4]
|
||||||
song['file']['battle']['hyper'] = filenames[5] if filenames[5] else song['file']['battle']['hyper']
|
else song["difficulty"]["battle"]["normal"]
|
||||||
|
)
|
||||||
|
song["difficulty"]["battle"]["hyper"] = (
|
||||||
|
difficulties[5]
|
||||||
|
if difficulties[5]
|
||||||
|
else song["difficulty"]["battle"]["hyper"]
|
||||||
|
)
|
||||||
|
song["file"]["battle"]["normal"] = (
|
||||||
|
filenames[4]
|
||||||
|
if filenames[4]
|
||||||
|
else song["file"]["battle"]["normal"]
|
||||||
|
)
|
||||||
|
song["file"]["battle"]["hyper"] = (
|
||||||
|
filenames[5]
|
||||||
|
if filenames[5]
|
||||||
|
else song["file"]["battle"]["hyper"]
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
song['genre'] = music_entry.find('fw_genre').text
|
song["genre"] = music_entry.find("fw_genre").text
|
||||||
song['comment'] = music_entry.find('genre').text
|
song["comment"] = music_entry.find("genre").text
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -529,11 +561,11 @@ class ImportPopn(ImportBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
for orig, rep in accent_lut.items():
|
for orig, rep in accent_lut.items():
|
||||||
songinfo['title'] = songinfo['title'].replace(orig, rep)
|
songinfo["title"] = songinfo["title"].replace(orig, rep)
|
||||||
songinfo['artist'] = songinfo['artist'].replace(orig, rep)
|
songinfo["artist"] = songinfo["artist"].replace(orig, rep)
|
||||||
songinfo['title_en'] = songinfo['title_en'].replace(orig, rep)
|
songinfo["title_en"] = songinfo["title_en"].replace(orig, rep)
|
||||||
songinfo['artist_en'] = songinfo['artist_en'].replace(orig, rep)
|
songinfo["artist_en"] = songinfo["artist_en"].replace(orig, rep)
|
||||||
songinfo['genre'] = songinfo['genre'].replace(orig, rep)
|
songinfo["genre"] = songinfo["genre"].replace(orig, rep)
|
||||||
songs.append(songinfo)
|
songs.append(songinfo)
|
||||||
|
|
||||||
return songs
|
return songs
|
||||||
@ -993,7 +1025,9 @@ class ImportPopn(ImportBase):
|
|||||||
mask & 0x4000000 > 0, # Battle hyper chart bit
|
mask & 0x4000000 > 0, # Battle hyper chart bit
|
||||||
)
|
)
|
||||||
|
|
||||||
elif self.version == VersionConstants.POPN_MUSIC_USANEKO or self.version == (VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP):
|
elif self.version == VersionConstants.POPN_MUSIC_USANEKO or self.version == (
|
||||||
|
VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP
|
||||||
|
):
|
||||||
# Based on M39:J:A:A:2018101500
|
# Based on M39:J:A:A:2018101500
|
||||||
|
|
||||||
# Normal offset for music DB, size
|
# Normal offset for music DB, size
|
||||||
@ -1083,7 +1117,9 @@ class ImportPopn(ImportBase):
|
|||||||
mask & 0x4000000 > 0, # Battle hyper chart bit
|
mask & 0x4000000 > 0, # Battle hyper chart bit
|
||||||
)
|
)
|
||||||
|
|
||||||
elif self.version == VersionConstants.POPN_MUSIC_PEACE or self.version == (VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP):
|
elif self.version == VersionConstants.POPN_MUSIC_PEACE or self.version == (
|
||||||
|
VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP
|
||||||
|
):
|
||||||
# Based on M39:J:A:A:2020092800
|
# Based on M39:J:A:A:2020092800
|
||||||
|
|
||||||
# Normal offset for music DB, size
|
# Normal offset for music DB, size
|
||||||
@ -1173,7 +1209,14 @@ class ImportPopn(ImportBase):
|
|||||||
mask & 0x4000000 > 0, # Battle hyper chart bit
|
mask & 0x4000000 > 0, # Battle hyper chart bit
|
||||||
)
|
)
|
||||||
|
|
||||||
elif self.version == VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES or self.version == (VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + DBConstants.OMNIMIX_VERSION_BUMP):
|
elif (
|
||||||
|
self.version == VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES
|
||||||
|
or self.version
|
||||||
|
== (
|
||||||
|
VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES
|
||||||
|
+ DBConstants.OMNIMIX_VERSION_BUMP
|
||||||
|
)
|
||||||
|
):
|
||||||
# Based on M39:J:A:A:2022061300
|
# Based on M39:J:A:A:2022061300
|
||||||
|
|
||||||
# Normal offset for music DB, size
|
# Normal offset for music DB, size
|
||||||
@ -4228,11 +4271,11 @@ if __name__ == "__main__":
|
|||||||
help="The access token to use with the remote BEMAPI server.",
|
help="The access token to use with the remote BEMAPI server.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--folder',
|
"--folder",
|
||||||
dest='folder',
|
dest="folder",
|
||||||
action='store',
|
action="store",
|
||||||
type=str,
|
type=str,
|
||||||
help='The path were a folder of files are stored.',
|
help="The path were a folder of files are stored.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Parse args, validate invariants.
|
# Parse args, validate invariants.
|
||||||
@ -4261,14 +4304,16 @@ if __name__ == "__main__":
|
|||||||
if args.bin:
|
if args.bin:
|
||||||
songs = popn.scrape(args.bin)
|
songs = popn.scrape(args.bin)
|
||||||
if args.xml:
|
if args.xml:
|
||||||
songs = popn.scrape_xml(args.xml, songs)
|
songs = popn.scrape_xml(args.xml, songs)
|
||||||
elif args.folder:
|
elif args.folder:
|
||||||
files = Path(args.folder).glob('*xml')
|
files = Path(args.folder).glob("*xml")
|
||||||
for file in files:
|
for filename in files:
|
||||||
try:
|
try:
|
||||||
songs = popn.scrape_xml(file, songs)
|
songs = popn.scrape_xml(filename, songs)
|
||||||
except:
|
except Exception:
|
||||||
raise Exception("Invalid XML (" + str(file) +")" )
|
# We should really be just catching invalid XML but I didn't write this
|
||||||
|
# nor do I have omnimix so I can't really test what it should do.
|
||||||
|
raise Exception(f"Invalid XML ({filename})")
|
||||||
elif args.server and args.token:
|
elif args.server and args.token:
|
||||||
songs = popn.lookup(args.server, args.token)
|
songs = popn.lookup(args.server, args.token)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user