commit 6f668fa9e0d5419a869f9da6f6c3fe4948fcefe0 Author: alyssadev Date: Wed Mar 13 12:19:12 2024 +1000 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d97893 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!get_latest.sh +!get_latest_voices.py +!README.md diff --git a/get_latest.sh b/get_latest.sh new file mode 100644 index 0000000..d8315c9 --- /dev/null +++ b/get_latest.sh @@ -0,0 +1,41 @@ +#!/bin/bash +export base="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $base +echo "Checking for program update..." +server_version="$(curl https://arcsidian.com/xivv/version.json 2>/dev/null)" +[ "$(cat version.json)" = "$server_version" ] && echo "Up to date: $server_version" || ( + echo "Downloading $server_version..." + curl -O https://arcsidian.com/xivv/XivVoices_Setup.exe + WINEPREFIX=$base/pfx wine XivVoices_Setup.exe /VERYSILENT /SP- + rm XivVoices_Setup.exe + tee version.json <<<"$server_version" + echo "Updated to $server_version" +) 2>/dev/null +rm $base/share $base/pfx/drive_c/Xiv_Voices/Data -f +ln -s $base/pfx/drive_c/Xiv_Voices $base/share +mkdir -p Data tmp bak +ln -s $base/Data $base/pfx/drive_c/Xiv_Voices/Data +rm -f share/{nameless,npcData,voiceNames,ignored,data}.json +echo "Updating metadata..." +wget -P share -c https://arcsidian.com/xivv/{nameless,npcData,voiceNames,ignored,data}.json 2>/dev/null +echo "Checking for updated voice lines..." +pids="" +while read url fn; do + [[ -z "$url" || -z "$fn" ]] && break + echo " - Downloading $fn..." + ( + key=$(<<<$url sed 's/.zip$//' | awk -F/ '{print $(NF-1) "/" $NF}') + keysize=$(<<<$fn sed 's/.zip$//' | awk -F. '{print $NF}') + mv "share/Data/$key" "bak/${key//\//_}" 2>/dev/null + curl -o "tmp/$fn" "$url" 2>/dev/null && unzip -d share/Data -P "$keysize#Arc" "tmp/$fn" 2>&1 >/dev/null && rm "tmp/$fn" && echo " - Downloaded $fn" + ) & + pids="$pids $!" + + if [[ $(jobs -r -p | wc -l) -ge 5 ]]; then + wait -n + fi +#done <<< $(echo "https://xivvoices.com/npcs/Alphinaud/Alphinauds_Voice.zip Alphinauds_Voice.1534982.zip") +done <<< $(python3 get_latest_voices.py) +echo "Waiting for downloads to complete..." +wait $pids +echo "Update complete" diff --git a/get_latest_voices.py b/get_latest_voices.py new file mode 100644 index 0000000..6e75b7f --- /dev/null +++ b/get_latest_voices.py @@ -0,0 +1,25 @@ +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)