Skip to content

Commit

Permalink
generator: option to control max txtp name length
Browse files Browse the repository at this point in the history
  • Loading branch information
bnnm committed Dec 28, 2020
1 parent 49aedca commit 5de94f1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions wwiser/wcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def _parse(self):
parser.add_argument('-gwd','--txtp-write-delays', help="Don't skip initial delay.\(some .txtp will start with some delay)", action='store_true')
parser.add_argument('-gs', '--txtp-silence', help="Silence by default parts that crossfade", action='store_true')
parser.add_argument('-gt', '--txtp-tagsm3u', help="Use shorter .txtp names and put full names in !tags.m3u", action='store_true')
parser.add_argument('-gtl', '--txtp-tagsm3u-limit', help="Use shorter names + m3u by limiting original names to N chars", type=int)

parser.add_argument('-gxnl','--txtp-x-noloops', help="Extra: don't loop sounds", action='store_true')
parser.add_argument('-gxnt','--txtp-x-notxtp', help="Extra: don't save .txtp", action='store_true')
Expand Down Expand Up @@ -207,6 +208,7 @@ def _execute(self, args, filenames):
generator.set_write_delays(args.txtp_write_delays)
generator.set_silence(args.txtp_silence)
generator.set_tagsm3u(args.txtp_tagsm3u)
generator.set_tagsm3u_limit(args.txtp_tagsm3u_limit)

generator.set_x_noloops(args.txtp_x_noloops)
generator.set_x_notxtp(args.txtp_x_notxtp)
Expand Down
9 changes: 7 additions & 2 deletions wwiser/wgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def set_silence(self, flag):
def set_tagsm3u(self, flag):
self._txtpcache.tagsm3u = flag

def set_tagsm3u_limit(self, value):
self._txtpcache.tagsm3u_limit = value

def set_x_noloops(self, flag):
self._txtpcache.x_noloops = flag

Expand Down Expand Up @@ -433,8 +436,10 @@ def _write_tagsm3u(self):
outname = outdir + "!tags.m3u"

with open(outname, 'w', newline="\r\n") as outfile:
outfile.write("# @ALBUM \n")
outfile.write("# $AUTOTRACK\n")
outfile.write("## @ALBUM \n")
outfile.write("## $AUTOALBUM\n")
outfile.write("## $AUTOTRACK\n")
outfile.write("# AUTOGENERATED BY WWISER\n")
outfile.write("\n")

for file in files:
Expand Down
11 changes: 9 additions & 2 deletions wwiser/wtxtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,18 @@ def _write_txtp_internal(self, printer):
longname = None
if self.txtpcache.tagsm3u:
longname = name
shortname = self._get_shortname() #todo should probably store after trimming
if not self.txtpcache.tagsm3u_limit:
shortname = self._get_shortname() #todo should probably store after trimming
else:
if len(longname) > self.txtpcache.tagsm3u_limit:
cutname = longname[0:self.txtpcache.tagsm3u_limit]
shortname = "%s~%04i" % (cutname, self.txtpcache.created)
else:
shortname = longname
name = shortname

shortname += ".txtp"
self.txtpcache._tag_names[shortname] = longname
self.txtpcache.add_tag_names(shortname, longname)

name += ".txtp"
logging.debug("txtp: saving '%s' (%s)", name, texthash)
Expand Down
5 changes: 5 additions & 0 deletions wwiser/wtxtp_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self):
self.write_delays = False
self.silence = False
self.tagsm3u = False
self.tagsm3u_limit = None

self.x_noloops = False
self.x_notxtp = False
Expand Down Expand Up @@ -99,6 +100,10 @@ def get_banks(self):
def get_tag_names(self):
return self._tag_names

def add_tag_names(self, shortname, longname):
self._tag_names[shortname] = longname


# paths for txtp
def normalize_path(self, path):
#path = path or '' #better?
Expand Down
2 changes: 1 addition & 1 deletion wwiser/wversion.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#autogenerated on build
WWISER_VERSION = "v20201224"
WWISER_VERSION = "v20201228"

0 comments on commit 5de94f1

Please sign in to comment.