2019-12-08 22:43:49 +01:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
from bemani.format import IIDXMusicDB
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
parser = argparse.ArgumentParser(description="A utility to patch a IIDX music database.")
|
|
|
|
parser.add_argument(
|
|
|
|
"infile",
|
|
|
|
help="Music DB to work with.",
|
|
|
|
type=str,
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"outfile",
|
|
|
|
help="Music DB to overwrite.",
|
|
|
|
type=str,
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--hide-leggendarias",
|
|
|
|
help="Hide leggendarias in normal folders.",
|
|
|
|
action="store_true",
|
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2022-03-18 05:32:04 +01:00
|
|
|
rfp = open(args.infile, 'rb')
|
|
|
|
data = rfp.read()
|
|
|
|
rfp.close()
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
db = IIDXMusicDB(data)
|
|
|
|
if args.hide_leggendarias:
|
|
|
|
for song in db.songs:
|
|
|
|
if song.title[-1:] == '†' or (
|
|
|
|
song.difficulties[0] == 0 and
|
|
|
|
song.difficulties[1] == 0 and
|
|
|
|
song.difficulties[2] == 12
|
|
|
|
):
|
2020-01-07 22:29:07 +01:00
|
|
|
print(f'Patching \'{song.title}\' to only appear in leggendaria folder!')
|
2019-12-08 22:43:49 +01:00
|
|
|
song.folder = 0x5C
|
|
|
|
|
|
|
|
print('Generating new database file...')
|
2022-03-18 05:32:04 +01:00
|
|
|
wfp = open(args.outfile, 'wb')
|
|
|
|
wfp.write(db.get_new_db())
|
|
|
|
wfp.close()
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|