Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shuffle an m3u playlist`
#!/bin/env python
import sys
import random
if __name__ == '__main__':
old_indices = []
new_indices = []
with open(sys.argv[1]) as f:
pl = f.read().split("\n")
desired = []
for i in range(1, len(pl[1:]), 2)
desired.append("{}\n{}".format(pl[i], pl[i+1]))
random.shuffle(desired)
split_desired = []
for foo in desired:
split_desired.extend(foo.split("\n"))
new_list = "\n".join([pl[0]] + split_desired)
with open(sys.argv[2], "w") as f:
f.write(new_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment