skyeweave/atlasimagecomposer/atlas.py

43 lines
1.3 KiB
Python
Raw Permalink Normal View History

2024-08-09 16:57:33 +00:00
import requests
from .cli import Paths
def fetch_image(servantid: str, imageid: str):
atlasurl = f"https://static.atlasacademy.io/JP/CharaFigure/{imageid}/{imageid}_merged.png"
savefolder = Paths.IMAGES / servantid
if not savefolder.is_dir():
savefolder.mkdir()
filelocation = savefolder / f"{imageid}.png"
with open(filelocation, 'wb') as handle:
response = requests.get(atlasurl, stream=True, timeout=10)
if not response.ok:
print(response)
for block in response.iter_content(1024):
if not block:
break
handle.write(block)
def fetch_info(servantid: str):
atlasurl = f"https://api.atlasacademy.io/basic/JP/servant/{servantid}?lang=en"
response = requests.get(atlasurl, timeout=10)
if not response.ok:
print(response)
data = response.json()
print(f"Fetching data and sprites for {data['name']} (ID: {servantid})")
def fetch_data(servantid: str):
fetch_info(servantid)
atlasurl = f"https://api.atlasacademy.io/raw/JP/servant/{servantid}?lore=false&expand=true&lang=en"
response = requests.get(atlasurl, timeout=10)
if not response.ok:
print(response)
data = response.json()
return { str(spritesheet["id"]): (spritesheet["faceX"], spritesheet["faceY"]) for spritesheet in data["mstSvtScript"] }