Package: osu-tools
osu!-tools for pythonDescriptionosu!-tools is a Python framework for interacting with various osu! APIs and file-types.Make requests to the osu! v1 API to view user, score, map or match information.Uses oppai-ng to get pp information for any given scoreRead osu!.db, scores.db and collection.db into a Python object, and export it to jsonInstallationpipinstallosu-toolsBasic ExamplesAPI v1>>importosutools# Authenticate a client using an osu! API token>>osu=osutools.OsuClient("token")Get User>>me=osu.fetch_user(username="flubb 4")>>print(f"{me}|{me.pp}pp | #{me.rank}Global")flubb4|7507.3pp|#8765 GlobalGet best 5 scores + show information>>best=me.fetch_best()[:5]>>forscoreinbest:..beatmap=score.fetch_map()..print(f"{score.pp}pp |{score.score}|{beatmap}|{score.mods}")431.448pp|1554216|WONDERFULWONDER(TVSize)[SimpleHeart]mappedbyKuki1537|DT399.029pp|44559304|FlamesWithinTheseBlackFeathers[Kowari's Extreme] mapped by Seni | NM387.581pp|2219153|AngelWithAShotgun(SpedUpVer.)[SacredBullet]mappedbySotarks|HDDT379.095pp|377539970|SaveMe[Tragedy]mappedbyDrummer|NM371.206pp|6547546|OnebyOne[Sotarks' Rampage] mapped by Elinor | HRGet information about a specific beatmap>>beatmap=osu.fetch_map(map_id=2788620)>>print(f"{beatmap.song_title}[{beatmap.difficulty_name}] |{beatmap.artist}|{beatmap.creator_name}")Sofia[Nyantiaz's Hard] | Clairo | QiyanaGet leaderboards and submitted scores for the beatmap>>leaderboard=beatmap.fetch_scores()>>my_score=beatmap.fetch_scores(username="flubb 4")[0]>>print(f"Best Score:{leaderboard[0]}\nMy Score:{my_score}")BestScore:HDDTHRscoreonbeatmap2788620byMikaylaMyScore:HDDTscoreonbeatmap2788620byflubb4DatabasesSet osu directory, and automatically read the databases.>>osu.set_osu_folder("path/to/folder")# Load the pp values for all local plays (enables faster processing of functions that use the pp value like get_best_scores_before()>>osu.scores_db.load_pp()Get the average length of all of your maps>>avg_map_length=sum([beatmap.lengthforbeatmapinosu.osu_db.map_list()])/float(len(osu.osu_db.map_list()))>>print(timedelta(milliseconds=avg_map_length))0:02:35.320889Get your top 10 ranked scores before 2020>>names=["flubb 4","ito","biglizard"]# I've changed my username a lot>>scores=osu.scores_db.get_best_scores_before(datetime.datetime(year=2020,month=1,day=1,tzinfo=timezone.utc),names=,ranked_only=True)>>forx,scoreinenumerate(scores[:5]):..print(f"{x+1}:{score.pp}play on{score.map.song_title}[{score.map.difficulty_name}] with{score.mods}")1:312.0760803222656playonSnowHalation(feat.BeasttrollMC)[Reform's Extra] with DT2:311.7738952636719playonHarumachiClover(SwingArrangement)[DictateEdit][Expert]withDT3:277.50250244140625playonYukinoHana[Sharlo's Insane] with DT4:272.4308776855469playonKiraKiraDays[Shiawase!!]withNM5:269.6291198730469playonNatsukoiHanabi[Insane]withDTExport your databases to JSON>>osu.osu_db.export()# saves to osu_db.json by default>>osu.scores_db.export("~/osu/scores.json")# can give custom pathPP CalculationGet pp for an SS on a given map with HDHR>>fromosutools.utilsimportMods>>fromosutools.oppaiimportOppai>>beatmap_path="96neko - Uso no Hibana (Enjoy) [Hanabi].osu">>mod_combo=Mods.HR&Mods.HD>>pp=Oppai.calculate_pp(beatmap_path,mods=mod_combo.value)>>print(pp)219.83245849609375Get pp for an online map>>beatmap=osu.fetch_map(1255495)>>pp=Oppai.calculate_pp_from_url(beatmap.download_url,mods=mod_combo.value,accuracy=99.5)>>print(pp)311.27484130859375Todoapi v2better errorsprobably some kind of internal ratelimit prevention?tests 👀discord integration utilities?download beatmapAcknowledgementshttps://github.com/Francesco149/oppai-ngfor the PP calculation, I just used ctypes to make it python