def downloadRecursive(): # Obtain list of absolute paths to all our tuneFile.paks paksDirectory = os.path.join(util.absPath, "data", "ios/gc2") tuneFilePaks = [ os.path.join(paksDirectory, filename) for filename in os.listdir(paksDirectory) if filename.startswith("tuneFile") and filename.endswith(".pak") ] # for each: Open pak, get stageparam.dat, close file stageParams = [] for tuneFilePak in tuneFilePaks: with open(tuneFilePak, "rb") as tuneFileData: stageParams.append( util.decryptPak(pakFile=tuneFileData.read(), onlyFiles=["stage_param.dat" ])["stage_param.dat"]) # Extract names, flatten lists and remove duplicates extractedStageNames = [ util.getNamesFromStageTEMP(datData=stageParam, search=b"\x64\x64", includes=0) for stageParam in stageParams ] extractedPreviewNames = [ util.getNamesFromStageTEMP(datData=stageParam, search=b"_sample", includes=7) for stageParam in stageParams ] extractedStageNames = [ name for namesList in extractedStageNames for name in namesList ] extractedPreviewNames = [ name for namesList in extractedPreviewNames for name in namesList ] # Yes i know i could just re-use code from downloadPreviews() and downloadChartdata() # But we would only be able to send loose stageParamData files so we go over the same # files many times which is inefficient, i don't want to rewrite it either. this is ok [ util.downloadIfNotExists(util.sampleUrl % previewName, bruteForce=False) for previewName in extractedPreviewNames ] [ util.downloadIfNotExists(util.stageUrl % stageName, bruteForce=False) for stageName in extractedStageNames ]
def downloadNewPaks(soup): paks = { "tunePak": soup.find("tunefile_pak").find("url").text, "modelPak": soup.find("model_pak").find("url").text, "skinPak": soup.find("skin_pak").find("url").text } [util.downloadIfNotExists(url, bruteForce=False) for url in paks.values()]
def downloadChartData(stageParamData): stageNames = util.getNamesFromStageTEMP(stageParamData, search=b"\x64\x64", includes=0) [ util.downloadIfNotExists(util.stageUrl % stageName, bruteForce=False) for stageName in stageNames ]
def downloadPreviews(stageParamData): previewNames = util.getNamesFromStageTEMP(stageParamData, search=b"_sample", includes=7) [ util.downloadIfNotExists(util.sampleUrl % previewName, bruteForce=False) for previewName in previewNames ]
def downloadChartUpdateData(soup): # Documentation on these # Looks like these are chart *Updates* that the server instructs the # client to update these files with these revisions. They are given # by start.php and stored in the client inside TunePreferences.xml stagePaks = soup.find_all("stage_pak") stageNames = [ stagePak.find("name").text + stagePak.find("date").text for stagePak in stagePaks ] [ util.downloadIfNotExists(util.stageUrl % stageName, bruteForce=False) for stageName in stageNames ]
def downloadMusic(): stageFolder = util.convertPath("ios/gc2/stage") for stageFilename in os.listdir(stageFolder): names = [ name for datData in util.getDatsFromZip( os.path.join(stageFolder, stageFilename)) for name in util.getNamesFromChart(datData) if not name.lower().endswith(("_hard", "_normal", "_easy", "_h", "_n", "_e")) ] names = list(dict.fromkeys(names)) # Removes duplicates [ util.downloadIfNotExists(util.musicUrl % name, bruteForce=False) for name in names ]
def downloadOldPaks(): [ util.downloadIfNotExists(util.pakUrl % oldPakName, bruteForce=False) for oldPakName in util.oldPakNames ]