feat: download all icons for the market-groups (#26)

This commit is contained in:
Patric Stout
2023-12-03 14:49:06 +01:00
committed by GitHub
parent 24d84f22fe
commit 294982b777
2 changed files with 45 additions and 8 deletions

View File

@@ -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: |

View File

@@ -1,5 +1,13 @@
import os
import requests
import sys
import yaml
if len(sys.argv) < 2:
print("Usage: python3 download_icons.py <path/to/eve-sde/fsd>")
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)