diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94a8d87..f59c90e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,7 +60,7 @@ jobs: - name: Fetch icons run: | - python download_icons.py + python download_icons.py sde/fsd - name: Publish to R2 bucket run: | diff --git a/download_icons.py b/download_icons.py index 0fa083d..b920f96 100644 --- a/download_icons.py +++ b/download_icons.py @@ -1,5 +1,13 @@ import os import requests +import sys +import yaml + +if len(sys.argv) < 2: + print("Usage: python3 download_icons.py ") + exit(1) + +path = sys.argv[1] folders = [ "res:/ui/texture/classes/fitting", @@ -7,7 +15,27 @@ folders = [ "res:/ui/texture/shared", "res:/ui/texture/windowicons", ] +files = {} +with open(f"{path}/marketGroups.yaml") as fp: + marketGroups = yaml.load(fp, Loader=yaml.CSafeLoader) + +with open(f"{path}/iconIDs.yaml") as fp: + iconIDs = yaml.load(fp, Loader=yaml.CSafeLoader) + +for marketGroupID, marketGroup in marketGroups.items(): + if "iconID" not in marketGroup or marketGroup["iconID"] == 0: + continue + + # Avatar related icons + topParentGroupID = marketGroupID + while "parentGroupID" in marketGroups[topParentGroupID]: + topParentGroupID = marketGroups[topParentGroupID]["parentGroupID"] + if topParentGroupID == 1396: + continue + + filename = iconIDs[marketGroup["iconID"]]["iconFile"].lower() + files[filename] = f"icons/{marketGroup['iconID']}" latest = requests.get("https://binaries.eveonline.com/eveclient_TQ.json").json() build = latest["build"] @@ -26,14 +54,23 @@ for line in resfile.split("\n"): continue res, path, _, _, _ = line.split(",") + if not res.endswith(".png"): + continue dirname = os.path.dirname(res) + if dirname not in folders and res not in files: + continue - if res.endswith(".png") and dirname in folders: - filename = res.split(":")[1][1:] - print(f"Downloading {filename} ...") - local_path = "dist/" + filename + filename = res.split(":")[1][1:] - os.makedirs(os.path.dirname(local_path), exist_ok=True) - with open(local_path, "wb") as f: - f.write(session.get(f"https://resources.eveonline.com/{path}").content) + if dirname in folders: + local_path = filename + else: + local_path = files[res] + ".png" + + print(f"Downloading {filename} to {local_path} ...") + local_path = f"dist/{local_path}" + + os.makedirs(os.path.dirname(local_path), exist_ok=True) + with open(local_path, "wb") as f: + f.write(session.get(f"https://resources.eveonline.com/{path}").content)