48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
|
import json
|
||
|
|
||
|
minimumPlays = 3
|
||
|
|
||
|
playcounts = json.load(open(file="./temp/listPlays.json", encoding="utf-8"))
|
||
|
musicinfo = json.load(open(file="./Data_decrypted/musicinfo.json", encoding="utf-8"))
|
||
|
musicinfoOmni = json.load(open(file="../08.18 & CHN/gamefiles/Omni/musicinfo.json", encoding="utf-8"))
|
||
|
|
||
|
finalList = {"songs": []}
|
||
|
|
||
|
# Adding all the 39.06 songs in the list
|
||
|
for music in musicinfo["items"]:
|
||
|
finalList["songs"].append({"id": music["id"], "uniqueId": music["uniqueId"]})
|
||
|
|
||
|
# Going over all the Omni songs and adding the ones that have been played more than X times to the final list
|
||
|
omniAdded = 0
|
||
|
omniRemoved = 0
|
||
|
for music in musicinfoOmni["items"]:
|
||
|
try:
|
||
|
song = next((item for item in playcounts["Omnimix"] if item["id"] == music["id"]), None)
|
||
|
songPlayCount = song["plays"]
|
||
|
|
||
|
if songPlayCount > minimumPlays:
|
||
|
finalList["songs"].append(
|
||
|
{
|
||
|
"id": music["id"],
|
||
|
"uniqueId": music["uniqueId"],
|
||
|
"nameJp": song["nameJp"],
|
||
|
"nameUs": song["nameUs"],
|
||
|
"Played": songPlayCount,
|
||
|
}
|
||
|
)
|
||
|
print("Added", (music["id"] + ": "), song["nameUs"], "from omnimix")
|
||
|
omniAdded += 1
|
||
|
else:
|
||
|
print("Skipped", (music["id"] + ": "), song["nameUs"])
|
||
|
omniRemoved += 1
|
||
|
except:
|
||
|
pass
|
||
|
|
||
|
print("Kept", omniAdded, "songs")
|
||
|
print("Removed", omniRemoved, "songs")
|
||
|
|
||
|
finalList["songs"].sort(key=lambda x: int(x["uniqueId"]), reverse=False)
|
||
|
updatedWordList = json.dumps(finalList, indent=4, ensure_ascii=False)
|
||
|
with open("./temp/finalList.json", "w", encoding="utf8") as outfile:
|
||
|
outfile.write(updatedWordList)
|