]> git.phdru.name Git - audio-cdr-video.git/commitdiff
Feat(audio/shuffle-playlist.py): Prepend directory
authorOleg Broytman <phd@phdru.name>
Sun, 27 Nov 2022 14:24:54 +0000 (17:24 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 27 Nov 2022 14:24:54 +0000 (17:24 +0300)
Prepend playlist directory to store random playlist
in a temporary place.

audio/shuffle-playlist.py

index 65c724a1c00e059ddeda68889292c7e447bb9b5d..4bf84ea5fff9fee0d6324963d35e4134ee095e7b 100755 (executable)
@@ -1,11 +1,18 @@
 #! /usr/bin/env python
 
-import sys
+import os.path
 import random
+import sys
+
+if len(sys.argv) != 3:
+    sys.exit("Usage: %s playlist random-list" % sys.argv[0])
 
 infile_name = sys.argv[1]
 outfile_name = sys.argv[2]
 
+prepend_dir = os.path.abspath(os.path.dirname(
+    os.path.expanduser(os.path.expandvars(infile_name))))
+
 infile = open(infile_name, 'r')
 lines = infile.readlines()
 infile.close()
@@ -14,5 +21,5 @@ random.shuffle(lines)
 
 outfile = open(outfile_name, 'w')
 for line in lines:
-    outfile.write(line)
+    outfile.write(os.path.join(prepend_dir, line))
 outfile.close()