ppy / osu-api

Public API for accessing osu! related data.
320 stars 16 forks source link

Help to download beatmaps by ID #288

Closed frixaco closed 4 years ago

frixaco commented 4 years ago

Hello, everyone I have a list of my beatmaps' IDs in text file and want to download beatmaps by their ID. The reason is that when I was reinstalling Windows all my beatmaps got corrupted, but I managed to get each beatmaps' ID. I'm beginner in programming (Python), have some experience with request. But I can't figure out how to use osu-api, my api-key, etc.. (even though I spent a few hours) Can someone give an example how to download a map (say, 1012634), please?

ThePooN commented 4 years ago

This is not a supported use case.

frixaco commented 4 years ago

This is not a supported use case.

Ok, I edited it

ThePooN commented 4 years ago

What I meant is, the API doesn't support downloading beatmaps.

frixaco commented 4 years ago

Oh. So there's not any way to (write a script) mass download beatmaps by their IDs?

frixaco commented 4 years ago

YESS! I found it! All I needed to do was import my cookies from my browser (check-out browser-cookie3 library of Python)

import browser_cookie3
import requests

cj = browser_cookie3.firefox()
url = 'https://osu.ppy.sh/beatmapsets/1012634/download'
r = requests.get(url, cookies=cj)

with open("map_name.osz", 'wb') as f:
    f.write(r.content)