ghetto automation glue for existing zsh/bash scripts
This commit is contained in:
parent
b6c3c6a454
commit
d75fcf3507
3 changed files with 122 additions and 0 deletions
23
divatool.py
23
divatool.py
|
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import utage
|
import utage
|
||||||
import db
|
import db
|
||||||
|
import xdudata
|
||||||
|
|
||||||
LANGUAGES = ["jpn", "eng", "rus"]
|
LANGUAGES = ["jpn", "eng", "rus"]
|
||||||
|
|
||||||
|
|
@ -115,6 +116,23 @@ def main():
|
||||||
"OLD", help="Directory with old quest files", nargs="?", type=str, default="."
|
"OLD", help="Directory with old quest files", nargs="?", type=str, default="."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# xdudata command
|
||||||
|
parser_xdudata = subparsers.add_parser(
|
||||||
|
"xdudata", help="XduPlayer Generation Automation"
|
||||||
|
)
|
||||||
|
parser_xdudata_subparsers = parser_xdudata.add_subparsers(
|
||||||
|
metavar="<command>", title="subcommand", dest="subcommand"
|
||||||
|
)
|
||||||
|
parser_xdudata_update = parser_xdudata_subparsers.add_parser(
|
||||||
|
"update", help="Update an XDUData directory"
|
||||||
|
)
|
||||||
|
parser_xdudata_update.add_argument(
|
||||||
|
"CACHE", help="files/ directory from XDU cache", type=str
|
||||||
|
)
|
||||||
|
parser_xdudata_update.add_argument("XDUDATA", help="old XDUData folder", type=str)
|
||||||
|
parser_xdudata_update.add_argument("TRANS", help="xdutranslations.git", type=str)
|
||||||
|
parser_xdudata_update.add_argument("EXTRACT", help="AV extraction folder", type=str)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.command == "adx":
|
if args.command == "adx":
|
||||||
|
|
@ -147,6 +165,11 @@ def main():
|
||||||
elif args.command == "diva":
|
elif args.command == "diva":
|
||||||
if args.subcommand == "quest":
|
if args.subcommand == "quest":
|
||||||
diva.quest.update_missions(args.INPUT, args.OLD, LANGUAGES)
|
diva.quest.update_missions(args.INPUT, args.OLD, LANGUAGES)
|
||||||
|
elif args.command == "xdudata":
|
||||||
|
if args.subcommand == "update":
|
||||||
|
xdudata.update_all(
|
||||||
|
args.CACHE, args.XDUDATA, args.TRANS, args.EXTRACT, LANGUAGES
|
||||||
|
)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
||||||
1
xdudata/__init__.py
Normal file
1
xdudata/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from .update import update_all
|
||||||
98
xdudata/update.py
Normal file
98
xdudata/update.py
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
import diva
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import utage
|
||||||
|
|
||||||
|
from distutils.dir_util import copy_tree, remove_tree
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
|
||||||
|
def update_all(cache_dir, update_dir, translation_dir, extract_dir, languages):
|
||||||
|
print("Copying images")
|
||||||
|
copy_images(cache_dir, update_dir)
|
||||||
|
|
||||||
|
print("Processing TSV files")
|
||||||
|
update_tsv(cache_dir, update_dir, translation_dir, languages)
|
||||||
|
|
||||||
|
print("Processing Quest Json files")
|
||||||
|
diva.quest.update_missions(cache_dir, translation_dir, languages)
|
||||||
|
|
||||||
|
# this code isn't going to run on windows because i need to rewrite it
|
||||||
|
# it just calls my zsh scripts and generates it that way, need to replace them
|
||||||
|
# with real python or something
|
||||||
|
print("Processing Sound Effects")
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(cache_dir, "Android/Asset/Sound/Se"),
|
||||||
|
os.path.join(extract_dir, "Se"),
|
||||||
|
)
|
||||||
|
subprocess.run("./update_se.zsh", shell=True, cwd=extract_dir)
|
||||||
|
copy_tree(os.path.join(extract_dir, "se"), os.path.join(update_dir, "Se"))
|
||||||
|
|
||||||
|
print("Processing BGM - don't forget to copy that loop file")
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(cache_dir, "Android/Asset/Sound/Bgm"),
|
||||||
|
os.path.join(extract_dir, "Bgm"),
|
||||||
|
)
|
||||||
|
subprocess.run("./update_bgm.zsh", shell=True, cwd=extract_dir)
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(extract_dir, "bgm"), os.path.join(update_dir, "Bgm")
|
||||||
|
)
|
||||||
|
|
||||||
|
print("Processing voices")
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(cache_dir, "Android/Asset/Sound/Voice"),
|
||||||
|
os.path.join(extract_dir, "Voice"),
|
||||||
|
)
|
||||||
|
subprocess.run("./update_voice.zsh", shell=True, cwd=extract_dir)
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(extract_dir, "voice"), os.path.join(update_dir, "Voice")
|
||||||
|
)
|
||||||
|
|
||||||
|
print("Processing movies - this might take forever")
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(cache_dir, "Common/Asset/Movie"),
|
||||||
|
os.path.join(extract_dir, "Movie"),
|
||||||
|
)
|
||||||
|
subprocess.run("./update_movie.zsh", shell=True, cwd=extract_dir)
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(extract_dir, "movie"),
|
||||||
|
os.path.join(update_dir, "Asset/Movie"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def update_tsv(cache_dir, update_dir, translation_dir, languages):
|
||||||
|
utage_tmp = tempfile.mkdtemp()
|
||||||
|
copy_tree(os.path.join(cache_dir, "Common/Asset/Utage"), utage_tmp)
|
||||||
|
utage.crypt.crypt_dir(
|
||||||
|
utage_tmp, bytearray("SampleSecretKey", "utf-8"), False, False
|
||||||
|
)
|
||||||
|
for encrypted in glob(
|
||||||
|
os.path.join(utage_tmp, "**/*.utage"), recursive=True
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
os.remove(encrypted)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
utage.translate.translate_dir(
|
||||||
|
utage_tmp,
|
||||||
|
os.path.join(update_dir, "Utage"),
|
||||||
|
os.path.join(translation_dir, "Missions"),
|
||||||
|
)
|
||||||
|
utage.names.update_names(utage_tmp, translation_dir, languages)
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(utage_tmp, "Diva"), os.path.join(update_dir, "Utage/Diva")
|
||||||
|
)
|
||||||
|
remove_tree(utage_tmp)
|
||||||
|
|
||||||
|
|
||||||
|
def copy_images(cache_dir, update_dir):
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(cache_dir, "Common/Asset/Image"),
|
||||||
|
os.path.join(update_dir, "Asset/Image"),
|
||||||
|
)
|
||||||
|
copy_tree(
|
||||||
|
os.path.join(cache_dir, "Common/Sample"),
|
||||||
|
os.path.join(update_dir, "Sample"),
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue