Created
June 12, 2024 05:46
-
-
Save WindClan/60891a96a0468b713fb27e8cfe0170e3 to your computer and use it in GitHub Desktop.
Roblox mass asset version downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import os | |
import json | |
import sys | |
fileExtensions = { | |
"1": ".png", | |
"2": ".rbxm", | |
"3": ".ogg", | |
"4": ".mesh", | |
"5": ".lua", | |
"8": ".rbxm", | |
"9": ".rbxl", | |
"10": ".rbxm", | |
"11": ".rbxm", | |
"12": ".rbxm", | |
"13": ".rbxm", | |
"38": ".rbxm" | |
} | |
headers = { | |
'User-Agent': 'Roblox/WinInet', | |
} | |
cookies = { | |
'.ROBLOSECURITY': '', #Only needed when downloading private files | |
} | |
def downloadAsset(assetId): | |
assetApi = "https://assetdelivery.roblox.com/v2/assetId/%s/version/%d" | |
if not os.path.isdir("downloads"): | |
os.mkdir("downloads") | |
status = 200 | |
lastVersion = 0 | |
while status == 200: | |
lastVersion = lastVersion + 1 | |
r = requests.get(assetApi.replace("%s",assetId).replace("%d",str(lastVersion)),headers=headers,cookies=cookies) | |
status = r.status_code | |
if status == 200: | |
data = json.loads(r.content) | |
try: | |
assetUrl = data["locations"][0]["location"] | |
extension = fileExtensions[str(data["assetTypeId"])] | |
download = requests.get(assetUrl,headers=headers,cookies=cookies, stream=True) | |
status = download.status_code | |
if status == 200: | |
print("Downloading "+assetId+" version "+str(lastVersion)+extension) | |
a = open("downloads/"+assetId+" version "+str(lastVersion)+extension, "wb") | |
a.write(download.content) | |
a.close() | |
else: | |
print(download) | |
except: | |
status = 0 | |
else: | |
print(r) | |
if __name__ == "__main__": | |
if not len(sys.argv) > 1: | |
print("Asset ID not specified") | |
else: | |
downloadAsset(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment