Last active
August 19, 2025 20:54
-
-
Save exurd/4ec486103337693490084589269d5f68 to your computer and use it in GitHub Desktop.
Roblox: Find meshes and textures for an accessory (or any asset that uses a sequential ID). Saves to `{ID}_{TYPE}.json` (16/04/2024)
This file contains hidden or 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
| """ | |
| FIND MESHES AND TEXTURES FOR AN ACCESSORY (16/04/2024) | |
| Saves found assets to `{ID}_{TYPE}.json` | |
| The Develop API Asset endpoint used could go down at any point, so use this | |
| script or forever hold your peace! https://devforum.roblox.com/t/3293093 | |
| """ | |
| import json | |
| import os | |
| import time | |
| from dotenv import load_dotenv # pip install python-dotenv | |
| import requests # pip install requests | |
| # Path to .env file with `RBX_TOKEN`: | |
| # https://github.com/exurd/DBR/blob/main/.example_env | |
| env_filepath = "/PATH/TO/.env" | |
| # The Asset ID with the creator ID you want to search for. | |
| assetId = 0 | |
| # The current Asset ID you want to start searching from. | |
| # Set to None if you want to start from the above Asset ID. | |
| current_assetId = None | |
| def validate_CSRF() -> str: | |
| """ | |
| Gets X-CSRF-Token for Roblox. | |
| """ | |
| requestSession.headers["X-CSRF-Token"] = None | |
| req = requestSession.post(url="https://auth.roblox.com/v2/logout", timeout=60) | |
| return req.headers["X-CSRF-Token"] | |
| if not os.path.isfile(env_filepath): | |
| raise Exception(f".env file \"{env_filepath}\" was not found") | |
| load_dotenv(env_filepath) | |
| requestSession = requests.Session() | |
| adapter = requests.adapters.HTTPAdapter(max_retries=5) | |
| requestSession.mount('https://', adapter) | |
| requestSession.mount('http://', adapter) | |
| requestSession.cookies[".ROBLOSECURITY"] = str(os.getenv("RBX_TOKEN")) | |
| requestSession.headers['Referer'] = "https://www.roblox.com" | |
| requestSession.headers["X-CSRF-Token"] = validate_CSRF() | |
| print("Loaded .env file!") | |
| def fetch_asset_details(asset_ids): | |
| """ | |
| Fetch assets from Roblox's Develop v1 Asset API. | |
| """ | |
| url = f"https://develop.roblox.com/v1/assets?assetIds={','.join(asset_ids)}" | |
| while True: | |
| response = requestSession.get(url) | |
| if response.status_code == 200: | |
| return response.json() | |
| print("Response went wack! Sleeping 5 secs...") | |
| time.sleep(5) | |
| def makeBatch(assetId): | |
| temp = [] | |
| for _ in range(50): | |
| assetId = assetId - 1 | |
| temp.append(str(assetId)) | |
| return temp, assetId | |
| asset_detail_req = fetch_asset_details([str(assetId)]) | |
| if asset_detail_req: | |
| userTargetId = int(asset_detail_req['data'][0]['creator']['targetId']) | |
| print(f"Target User ID: {userTargetId}") | |
| current_assetId = current_assetId or assetId | |
| while True: | |
| current_batch, current_assetId = makeBatch(current_assetId) | |
| print("Checking", current_assetId) | |
| asset_details_req = fetch_asset_details(current_batch) | |
| for asset_detail in asset_details_req['data']: | |
| if int(asset_detail['creator']['targetId']) == userTargetId: | |
| print(f"Found Asset {asset_detail['id']} as {asset_detail['type']}!") | |
| with open(f"{asset_detail['id']}_{asset_detail['type']}.json", "w", encoding="utf-8") as f: | |
| json.dump(asset_detail, f, ensure_ascii=False, indent=4) | |
| time.sleep(1.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment