From: Oleg Broytman Date: Sun, 27 Nov 2022 14:24:54 +0000 (+0300) Subject: Feat(audio/shuffle-playlist.py): Prepend directory X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=626fd0a28d91d721f330a7467cbab9117bda0059;p=audio-cdr-video.git Feat(audio/shuffle-playlist.py): Prepend directory Prepend playlist directory to store random playlist in a temporary place. --- diff --git a/audio/shuffle-playlist.py b/audio/shuffle-playlist.py index 65c724a..4bf84ea 100755 --- a/audio/shuffle-playlist.py +++ b/audio/shuffle-playlist.py @@ -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()