From 626fd0a28d91d721f330a7467cbab9117bda0059 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 27 Nov 2022 17:24:54 +0300 Subject: [PATCH] Feat(audio/shuffle-playlist.py): Prepend directory Prepend playlist directory to store random playlist in a temporary place. --- audio/shuffle-playlist.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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() -- 2.39.5