jack3898 / ohssbot

GNU General Public License v3.0
0 stars 0 forks source link

Implement hot beatmap downloads on replay render request #8

Closed jack3898 closed 7 months ago

jack3898 commented 7 months ago

Now I have written an open source npm package osr-loader, I can start adding it to this project.

Using the hash read from a replay file, I can determine the beatmap details using the Osu! api:

https://osu.ppy.sh/api/get_beatmaps?k=YOUR_API_KEY&h=MAP_HASH

The above uses the legacy API. At some point, I will transition this package to the new OAuth 2 API for authentication. But for now, the legacy API does what I need.

Which will give me an important key, the beatmapset_id, which I can construct a download URL with.

Then I will get a .osz file, which is just zip file in disguise. I can unzip it, store it in a songs directory, then the renderer will use it.

The songs should be stored in .data/songs, and Danser configured to read there. Then when the render is done, delete said beatmap.

In the future, caching could be looked at to skip having to go to Osu! all the time for the songs. But again, for now this will do.

Also, as this could be abused, I will spin up a ticket that will add rate limits to the render command so that only a certain amount of replays can be rendered in a given hour.

jack3898 commented 7 months ago

I have been unable to use Osu's official servers for replay downloads. But I have found beatconnect.io! They are an Osu! beatmap mirror that will allow me to download beatmaps. I have fetched an API key if I ever need it. All beatmaps that come from this resource will have their checksums validated to ensure that the contents of the download match exactly what the replay expects.

I have also implemented a secure OAuth flow to the bot, so I no longer rely on the legacy API. This will allow me to use the beatmap checksum from the replay to lookup the ID, then using the ID download the map from beatconnect.io.

jack3898 commented 7 months ago

See 3f58355c4201227eabe70c7f5c2966a43d2d21ab It is completed (I should have tagged the commit with this issue number)