Rbxdownload.py - Download EVERY version of an asset

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])

This downloads every single version of an asset
I made this a while back and just rediscovered it

This is very useful if you need to archive old assets

7 Likes

Can you explain how to use it? You just gave us code with no explanation…

1 Like

you run
py rbxdownload.py [ASSETID]

2 Likes

Is it okay if i take your software and upgrade it?

1 Like

I don’t care at all
Do whatever you want

2 Likes

fyi for anyone who wants to use this now: the cookie is now needed for all downloads and not just private ones

Ok, So since your cookie is needed, that seems a little suspicious to me but hey I may be wrong. Does this code download anyone’s assets or only your own?

It’s purely logical; if you could download any place with any version, it wouldn’t be so secure, would it?
It requires cookies to determine if you are logged in to an account with access to that place.

Ah, That makes sense, Thanks for that!

The cookie is needed due to some Roblox endpoint changes that mean the endpoint won’t return anything if you don’t have a token to deter scrapers

To answer your question:
Any asset you have access to you can download

1 Like