def get_pp_infos(beatmap_id): BUFSIZE = 2000000 accuracys = [100, 99, 98, 97] mods = [pyoppai.nomod, pyoppai.hr, pyoppai.hd, pyoppai.dt, pyoppai.dt | pyoppai.hd, pyoppai.dt | pyoppai.hr, pyoppai.hd | pyoppai.hr, pyoppai.dt | pyoppai.hr | pyoppai.hd] mods_name = ["Nomod", "HR", "HD", "DT", "HDDT", "HRDT", "HDHR", "HRHDDT"] pp_results = {} ctx = pyoppai.new_ctx() buf = pyoppai.new_buffer(BUFSIZE) b = pyoppai.new_beatmap(ctx) err = pyoppai.err(ctx) if err: print(err) pass for accuracy in accuracys: i = 0 for mod in mods: pyoppai.parse(constants.Paths.beatmapsDownloadsPermanent + "/" + str(beatmap_id) + ".osu", b, buf, BUFSIZE, False, constants.Paths.beatmapsDownloadsPermanent) dctx = pyoppai.new_d_calc_ctx(ctx) pyoppai.apply_mods(b, mod) stars, aim, speed, _, _, _, _ = pyoppai.d_calc(dctx, b) _, pp, _, _, _ = pyoppai.pp_calc_acc(ctx, aim, speed, b, accuracy, mod) err = pyoppai.err(ctx) if err: print(err) pass pp_results["pp_" + str(accuracy) + "_" + mods_name[i]] = round(pp) i += 1 return pp_results
def checkOppaiErrors(self): log.debug("oppai ~> Checking oppai errors...") err = pyoppai.err(self._oppai_ctx) if err: log.error(str(err)) raise OppaiError(err) log.debug("oppai ~> No errors!")
for mod in mods: pyoppai.parse(downloadDirr + "/" + beatmap, b, buf, BUFSIZE, False, downloadDirr) dctx = pyoppai.new_d_calc_ctx(ctx) pyoppai.apply_mods(b, mod) stars, aim, speed, _, _, _, _ = pyoppai.d_calc(dctx, b) acc, pp, aim_pp, speed_pp, acc_pp = pyoppai.pp_calc_acc( ctx, aim, speed, b, accuracy, mod) try: data.append(round(pp)) except OverflowError: #If pp = infinite data.append( 2147483647) #max sqlite int 4 bytes value if pyoppai.err(ctx) != "Could not find General info": try: cursor.execute( "INSERT INTO beatmaps (beatmapId ,songId ,diff_params ,stars ,combo ,bpm ,lenght ,drain ,version ,title ,creator ,artist ,ranked ,PP_100 ,PP_100_HR ,PP_100_HD ,PP_100_DT ,PP_100_DTHD ,PP_100_DTHR ,PP_100_HRHD ,PP_100_DTHRHD ,PP_99 ,PP_99_HR ,PP_99_HD ,PP_99_DT ,PP_99_DTHD ,PP_99_DTHR ,PP_99_HRHD ,PP_99_DTHRHD ,PP_98 ,PP_98_HR ,PP_98_HD ,PP_98_DT ,PP_98_DTHD ,PP_98_DTHR ,PP_98_HRHD ,PP_98_DTHRHD ,PP_97 ,PP_97_HR ,PP_97_HD ,PP_97_DT ,PP_97_DTHD ,PP_97_DTHR ,PP_97_HRHD ,PP_97_DTHRHD) VALUES(" + "?," * 44 + " ?)", data) conn.commit() except sqlite3.IntegrityError: pass except OverflowError: pass done += 1 ended = time.time() conn.close() print("\033[94m[" + u"\u2588" * 50 + "]\033[0m 100% (" + str(done) + "/" +
def chk(ctx): err = pyoppai.err(ctx) if err: print(err) sys.exit(1)
def chk(ctx): err = pyoppai.err(ctx) if err: print(err)