ported update_bgm to python
This commit is contained in:
parent
404de87624
commit
cb0a4d8bf6
2 changed files with 53 additions and 15 deletions
|
|
@ -7,6 +7,8 @@ from contextlib import contextmanager
|
|||
from distutils.dir_util import copy_tree
|
||||
from glob import glob
|
||||
|
||||
from adx import extract_loop_data_from_dir
|
||||
|
||||
OPERATING_SYSTEM = os.name
|
||||
|
||||
|
||||
|
|
@ -35,10 +37,7 @@ def process_se(cache_dir, extract_dir, update_dir):
|
|||
run_program(acb_files, cmd=acb_cmd)
|
||||
|
||||
hca_files = [
|
||||
file
|
||||
for file in glob(
|
||||
"{}/{}*/**/*.hca".format(from_dir, acb_prefix), recursive=True
|
||||
)
|
||||
file for file in glob("{}/**/*.hca".format(from_dir), recursive=True)
|
||||
]
|
||||
run_program(hca_files, cmd="clHCA")
|
||||
|
||||
|
|
@ -85,10 +84,53 @@ def process_bgm(cache_dir, extract_dir, update_dir):
|
|||
os.path.join(cache_dir, "Android/Asset/Sound/Bgm"),
|
||||
os.path.join(extract_dir, "Bgm"),
|
||||
)
|
||||
subprocess.run(os.path.join("TODO", "update_bgm.zsh"), shell=True, cwd=extract_dir)
|
||||
copy_tree(
|
||||
os.path.join(extract_dir, "bgm_extracted"), os.path.join(update_dir, "Bgm")
|
||||
)
|
||||
|
||||
from_dir = "Bgm"
|
||||
to_dir = "Bgm_Extracted"
|
||||
loop_file = "loop.json"
|
||||
|
||||
pool = get_pool()
|
||||
|
||||
with change_cwd(extract_dir):
|
||||
os.makedirs(to_dir, exist_ok=True)
|
||||
|
||||
to_del = glob("{}/**/*.adx".format(from_dir), recursive=True)
|
||||
for file in to_del:
|
||||
os.remove(file)
|
||||
|
||||
acb_files = [file for file in glob("{}/*.acb".format(from_dir))]
|
||||
acb_cmd = get_dotnet_cmd("acb_extract.exe")
|
||||
run_program(acb_files, cmd=acb_cmd)
|
||||
|
||||
adx_files = [
|
||||
file for file in glob("{}/**/*.adx".format(from_dir), recursive=True)
|
||||
]
|
||||
partial_ffmpeg_cmd = functools.partial(run_program, cmd="ffmpeg")
|
||||
wav_cmds = [
|
||||
[
|
||||
"-i",
|
||||
os.path.abspath(file),
|
||||
"-acodec",
|
||||
"libopus",
|
||||
"-ab",
|
||||
"192k",
|
||||
"-af",
|
||||
"aresample=48000",
|
||||
os.path.abspath(
|
||||
"{}/{}.opus".format(
|
||||
to_dir, os.path.splitext(os.path.basename(file))[0],
|
||||
)
|
||||
),
|
||||
"-n",
|
||||
]
|
||||
for file in adx_files
|
||||
]
|
||||
pool.map(partial_ffmpeg_cmd, wav_cmds)
|
||||
|
||||
extract_loop_data_from_dir(from_dir, loop_file)
|
||||
shutil.copy2(loop_file, os.path.join(to_dir, "BgmLoop.json"))
|
||||
|
||||
copy_tree(os.path.join(extract_dir, to_dir), os.path.join(update_dir, "Bgm"))
|
||||
|
||||
|
||||
def process_voice(cache_dir, extract_dir, update_dir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue