#!/usr/bin/env python3 """손님 NPC 에셋 찾기(인증 없이 공개 API만 씀). python3 tools/npc_search.py store "low poly cat" [more queries...] # Creator Store 모델 검색 python3 tools/npc_search.py catalog "hair" [--free] [--bundles] # 아바타 상점(Roblox 제작) 검색 python3 tools/npc_search.py bundle 284 [...] # 번들 구성품 ID 보기 store: 무료·스크립트 없음만 보여 줍니다. 열: id, 투표(찬성/전체), 메시파트 수, 삼각형 수, 크리에이터, 이름. catalog/bundle 은 요청이 많으면 429/빈 오류가 나서 요청마다 몇 초씩 쉽니다. """ import json import sys import time import urllib.parse import urllib.request def get(url, tries=4): for attempt in range(tries): try: req = urllib.request.Request(url, headers={"User-Agent": "bunsik-tycoon-tools"}) with urllib.request.urlopen(req, timeout=60) as r: return json.loads(r.read()) except Exception as e: # 429 등은 잠깐 쉬고 다시 if attempt == tries - 1: return {"errors": [str(e)]} time.sleep(8 * (attempt + 1)) def store(query, pages=2): rows = [] token = "" for _ in range(pages): url = ("https://apis.roblox.com/toolbox-service/v2/assets:search?searchCategoryType=Model&maxPageSize=100&query=" + urllib.parse.quote(query) + (f"&pageToken={urllib.parse.quote(token)}" if token else "")) d = get(url) for it in d.get("creatorStoreAssets", []): a = it["asset"] price = it.get("creatorStoreProduct", {}).get("purchasePrice", {}).get("quantity", {}).get("significand", 0) if a.get("hasScripts") or price: continue v = it.get("voting", {}) rows.append((a["id"], v.get("upVotes", 0), v.get("voteCount", 0), a.get("instanceCounts", {}).get("meshPart", 0), a.get("objectMeshSummary", {}).get("triangles", 0), it["creator"].get("name"), a["name"])) token = d.get("nextPageToken") if not token: break return rows def catalog(keyword, free=False, bundles=False): q = {"keyword": keyword, "creatorName": "Roblox", "limit": 120} if free: q["maxPrice"] = 0 d = get("https://catalog.roblox.com/v2/search/items/details?" + urllib.parse.urlencode(q)) out = [] for x in d.get("data", []): if bundles and x["itemType"] != "Bundle": continue out.append((x["itemType"], x.get("assetType", x.get("bundleType")), x["id"], x["name"], x.get("price"), x.get("favoriteCount"))) return out, d.get("errors") def bundle(bid): d = get(f"https://catalog.roblox.com/v1/bundles/{bid}/details") return d.get("name"), [(i["type"], i["id"], i["name"]) for i in d.get("items", [])] def main(argv): if not argv: print(__doc__) return 2 cmd, args = argv[0], [a for a in argv[1:] if not a.startswith("--")] if cmd == "store": for q in args: print(f"== {q}") for r in sorted(store(q), key=lambda r: -r[2])[:40]: print(f"{r[0]}\t{r[1]}/{r[2]}\tmp={r[3]}\ttri={r[4]}\t{r[5]}\t{r[6]}") elif cmd == "catalog": for q in args: rows, err = catalog(q, "--free" in argv, "--bundles" in argv) print(f"== {q} {err or ''}") for r in rows: print("\t".join(str(c) for c in r)) time.sleep(6) elif cmd == "bundle": for b in args: name, items = bundle(b) print(f"== {b} {name}") for t in items: print("\t".join(str(c) for c in t)) time.sleep(3) return 0 if __name__ == "__main__": sys.exit(main(sys.argv[1:]))