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,9 +59,13 @@ class App(object):
def start(self):
print("TXTP dumper start")
filenames = []
for filename in self.args.files:
filenames += glob.glob(filename)
if os.path.isfile(filename): #for files in paths with regex-like format
filenames += [filename]
else:
filenames += glob.glob(filename)
for filename in filenames:
path = self.args.output or '.'

View File

@ -24,7 +24,7 @@ class Cli(object):
" %(prog)s * -r -fss 1\n"
" - make .txtp for all files in any subdirs with at least 1 subsong\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"
" %(prog)s *.scd -r -fd -l 2\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"))
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('-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('-s', dest='subsong_start', help="Start subsong", type=int)
p.add_argument('-S', dest='subsong_end', help="End subsong", type=int)
@ -270,13 +271,17 @@ class TxtpMaker(object):
return None
txt = self.info.stream_name
# remove paths #todo maybe config/replace?
pos = txt.rfind('\\')
if pos >= 0:
txt = txt[pos+1:]
pos = txt.rfind('/')
if pos >= 0:
txt = txt[pos+1:]
# remove paths
if self.cfg.allow_internal_paths:
txt = txt.replace("\\", "~")
txt = txt.replace("/", "~")
else:
pos = txt.rfind('\\')
if pos >= 0:
txt = txt[pos+1:]
pos = txt.rfind('/')
if pos >= 0:
txt = txt[pos+1:]
# remove bad chars
badchars = ['%', '*', '?', ':', '\"', '|', '<', '>']
@ -613,6 +618,7 @@ class App(object):
# subsongs should treat repeat names separately? pass flag?
#maker.reset(rename_map)
processing = False
while True:
try:
# main call to vgmstream
@ -623,10 +629,12 @@ class App(object):
# basic parse of vgmstream info
maker.parse(output_b)
processing = True
except (subprocess.CalledProcessError, ValueError) as e:
log.debug("ignoring CLI error in %s #%s: %s", filename_in, target_subsong, str(e))
errors += 1
break
if not processing: #stop but only if first subsong fails
break
if target_subsong == subsong_start:
log.debug("processing %s...", filename_in_clean)
@ -647,7 +655,7 @@ class App(object):
target_subsong += 1
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):
os.remove(filename_out)