hitsounds/spelunker/generate_top_diff.py
2023-05-19 17:55:53 -05:00

47 lines
No EOL
1.3 KiB
Python

in_file_path = r"C:\Users\mzhan\AppData\Local\osu!\Songs\1145452 Unknown Artist - Spelunker\Unknown Artist - Spelunker (IOException) [top-rhythm'].osu"
out_file_path = r"C:\Users\mzhan\AppData\Local\osu!\Songs\1145452 Unknown Artist - Spelunker\Unknown Artist - Spelunker (IOException) [Prece Enter Key].osu"
positions = [
(317, 289),
(225, 305),
(151, 253),
(135, 161),
(186, 87),
(278, 69),
(352, 121),
(369, 214),
]
with open(in_file_path, "rb") as f:
data = f.readlines()
with open(out_file_path, "wb") as f:
section = b""
c = 0
for line in data:
if line.startswith(b"Version"):
line = line.replace(b"top-rhythm'", b"Prece Enter Key")
line = line.strip()
if not line: continue
if line.startswith(b"[") and line.endswith(b"]"):
section = line.lstrip(b"[").rstrip(b"]")
print(section, line)
if section != b"HitObjects":
f.write(line + b"\n")
continue
parts = line.split(b",")
if len(parts) > 2:
x, y = positions[c]
parts[0] = str(x).encode("utf-8")
print(parts)
parts[1] = str(y).encode("utf-8")
c = (c + 1) % len(positions)
line = b",".join(parts)
f.write(line + b"\n")