xivvoices_updater/get_latest_voices.py
alyssadev 6f668fa9e0 init
2024-03-13 12:19:12 +10:00

25 lines
849 B
Python

from urllib.request import urlopen
from json import load, dump
from pathlib import Path
from urllib.parse import urlparse
from os.path import basename
from sys import stderr
manifest = load(urlopen("https://arcsidian.com/xivv/manifest.json"))
get = []
for key in manifest.keys():
p = Path(f"share/Data/{key}")
if p.exists():
s = sum(f.stat().st_size for f in p.glob('**/*') if f.is_file())
if s == manifest[key]:
continue
# print(f"{p} {s} != {manifest[key]}", file=stderr)
url = f"https://xivvoices.com/npcs/{key}.zip"
fn = f"{basename(key)}.{manifest[key]}.zip"
print(f"{url} {fn}")
# print(f"curl --limit-rate 3M -o 'tmp/{fn}' '{url}' && rm -rf 'share/Data/{key}' && unzip -d share/Data -P '{manifest[key]}#Arc' tmp/{fn} && rm 'tmp/{fn}'")
with open("share/manifest.json", "w") as f:
dump(manifest,f,indent=2)