txtp tools: tweaks

This commit is contained in:
bnnm 2024-01-05 17:38:13 +01:00
parent 96348f12db
commit df53c0c6fc
2 changed files with 23 additions and 11 deletions

View File

@ -59,8 +59,12 @@ class App(object):
def start(self): def start(self):
print("TXTP dumper start") print("TXTP dumper start")
filenames = [] filenames = []
for filename in self.args.files: for filename in self.args.files:
if os.path.isfile(filename): #for files in paths with regex-like format
filenames += [filename]
else:
filenames += glob.glob(filename) filenames += glob.glob(filename)
for filename in filenames: for filename in filenames:

View File

@ -24,7 +24,7 @@ class Cli(object):
" %(prog)s * -r -fss 1\n" " %(prog)s * -r -fss 1\n"
" - make .txtp for all files in any subdirs with at least 1 subsong\n" " - make .txtp for all files in any subdirs with at least 1 subsong\n"
" (ignores formats without subsongs)\n\n" " (ignores formats without subsongs)\n\n"
" %(prog)s bgm.fsb -in -fcm 2 -fms 5.0\n" " %(prog)s bgm.fsb -in -fcm 2 -fsm 5.0\n"
" - make .txtp for subsongs with at least 2 channels and 5 seconds\n\n" " - make .txtp for subsongs with at least 2 channels and 5 seconds\n\n"
" %(prog)s *.scd -r -fd -l 2\n" " %(prog)s *.scd -r -fd -l 2\n"
" - make .txtp for all .scd in subdirs, ignoring dupes, one .txtp per 2ch\n\n" " - make .txtp for all .scd in subdirs, ignoring dupes, one .txtp per 2ch\n\n"
@ -53,6 +53,7 @@ class Cli(object):
"* may be inside <...> for conditional text\n")) "* may be inside <...> for conditional text\n"))
p.add_argument('-z', dest='zero_fill', help="Zero-fill subsong number (default: auto per subsongs)", type=int) p.add_argument('-z', dest='zero_fill', help="Zero-fill subsong number (default: auto per subsongs)", type=int)
p.add_argument('-ie', dest='no_internal_ext', help="Remove internal name's extension if any", action='store_true') p.add_argument('-ie', dest='no_internal_ext', help="Remove internal name's extension if any", action='store_true')
p.add_argument('-ip', dest='allow_internal_paths', help="Replace internal name's / paths with ~ (otherwise removed)", action='store_true')
p.add_argument('-m', dest='mini_txtp', help="Create mini-txtp", action='store_true') p.add_argument('-m', dest='mini_txtp', help="Create mini-txtp", action='store_true')
p.add_argument('-s', dest='subsong_start', help="Start subsong", type=int) p.add_argument('-s', dest='subsong_start', help="Start subsong", type=int)
p.add_argument('-S', dest='subsong_end', help="End subsong", type=int) p.add_argument('-S', dest='subsong_end', help="End subsong", type=int)
@ -270,7 +271,11 @@ class TxtpMaker(object):
return None return None
txt = self.info.stream_name txt = self.info.stream_name
# remove paths #todo maybe config/replace? # remove paths
if self.cfg.allow_internal_paths:
txt = txt.replace("\\", "~")
txt = txt.replace("/", "~")
else:
pos = txt.rfind('\\') pos = txt.rfind('\\')
if pos >= 0: if pos >= 0:
txt = txt[pos+1:] txt = txt[pos+1:]
@ -613,6 +618,7 @@ class App(object):
# subsongs should treat repeat names separately? pass flag? # subsongs should treat repeat names separately? pass flag?
#maker.reset(rename_map) #maker.reset(rename_map)
processing = False
while True: while True:
try: try:
# main call to vgmstream # main call to vgmstream
@ -623,9 +629,11 @@ class App(object):
# basic parse of vgmstream info # basic parse of vgmstream info
maker.parse(output_b) maker.parse(output_b)
processing = True
except (subprocess.CalledProcessError, ValueError) as e: except (subprocess.CalledProcessError, ValueError) as e:
log.debug("ignoring CLI error in %s #%s: %s", filename_in, target_subsong, str(e)) log.debug("ignoring CLI error in %s #%s: %s", filename_in, target_subsong, str(e))
errors += 1 errors += 1
if not processing: #stop but only if first subsong fails
break break
if target_subsong == subsong_start: if target_subsong == subsong_start:
@ -647,7 +655,7 @@ class App(object):
target_subsong += 1 target_subsong += 1
if target_subsong % 200 == 0: if target_subsong % 200 == 0:
log.info("%s/%s subsongs... (%s dupes, %s errors)", target_subsong, maker.info.stream_count, dupes, errors) log.info("%s/%s subsongs... (%s done, %s dupes, %s errors)", target_subsong, maker.info.stream_count, created, dupes, errors)
if os.path.exists(filename_out): if os.path.exists(filename_out):
os.remove(filename_out) os.remove(filename_out)