Skip to content

Instantly share code, notes, and snippets.

@BlauFx
Last active August 17, 2023 21:04
Show Gist options
  • Save BlauFx/d47784ab05725c7002c597d008786bad to your computer and use it in GitHub Desktop.
Save BlauFx/d47784ab05725c7002c597d008786bad to your computer and use it in GitHub Desktop.
Download osu beatmaps via the chumu.moe api
import requests, time
def downloadMap(id):
urlSetInfo = f'https://api.chimu.moe/v1/set/{id}'
url = f'https://api.chimu.moe/v1/download/{id}'
r1 = requests.get(urlSetInfo)
raw = r1.content
text = raw.decode(r1.encoding)
osuFile = text.index('OsuFile":"')
osuFileEnd = text[osuFile:].index('(')
start = int(osuFile) + 10
end = osuFile + osuFileEnd - 1
#print(text)
NameOfFile = f"{id} {str(text)[start:end]}.osz"
#print(NameOfFile)
requestMap = requests.get(url)
NameOfFile = NameOfFile.replace("/", "_")
with open(NameOfFile, 'wb') as f:
f.write(requestMap.content)
file = open('beatmapsIDs.txt', 'r')
while True:
line = file.readline().replace('\n', '')
if not line:
break
print(line)
downloadMap(line)
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment