arrowverse.epls: Add extras!
[epls] / mkm3u
diff --git a/mkm3u b/mkm3u
index 3f5a5dd..9c50c3e 100755 (executable)
--- a/mkm3u
+++ b/mkm3u
@@ -81,7 +81,7 @@ URL_SAFE_P = 256*[False]
 for ch in \
     b"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
     b"abcdefghijklmnopqrstuvwxyz" \
-    b"0123456789" b"!$%-.,/":
+    b"0123456789" b"!$%_-.,/":
   URL_SAFE_P[ch] = True
 def urlencode(s):
   return "".join((URL_SAFE_P[ch] and chr(ch) or "%%%02x" % ch
@@ -545,6 +545,7 @@ class Playlist (object):
                       (ch.duration, label, ch.title, ch.url))
 
   def dump(me, f):
+    if opts.list_name is not None: f.write("LIST %s\n" % opts.list_name)
     if me.series_title is not None and \
        me.nseries > 1 and not me.single_series_p:
       raise ExpectedError("can't force series name for multi-series list")
@@ -883,12 +884,15 @@ class EpisodeListParser (object):
     return me._pl
 
 op = OP.OptionParser \
-  (usage = "%prog [-Dc] [-M DEPS] [-d CACHE] [-o OUT] [-s SERIES] EPLS\n"
+  (usage = "%prog [-Dc] [-L NAME] [-M DEPS] [-d CACHE] [-o OUT] [-s SERIES] EPLS\n"
             "%prog -i -d CACHE",
    description = "Generate M3U playlists from an episode list.")
 op.add_option("-D", "--dump",
               dest = "dump", action = "store_true", default = False,
               help = "Dump playlist in machine-readable form")
+op.add_option("-L", "--list-name", metavar = "NAME",
+              dest = "list_name", type = "str", default = None,
+              help = "Set the playlist name")
 op.add_option("-M", "--make-deps", metavar = "DEPS",
               dest = "deps", type = "str", default = None,
               help = "Write a `make' fragment for dependencies")
@@ -941,6 +945,9 @@ try:
     ep.parse_file(argv[0])
     pl = ep.done()
 
+    if opts.list_name is None:
+      opts.list_name, _ = OS.path.splitext(OS.path.basename(argv[0]))
+
     if opts.dump: outfn = pl.dump
     else: outfn = pl.write
     if opts.output is None or opts.output == "-":