Prepend playlist directory to store random playlist
in a temporary place.
#! /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()
outfile = open(outfile_name, 'w')
for line in lines:
- outfile.write(line)
+ outfile.write(os.path.join(prepend_dir, line))
outfile.close()