Exporting m3u playlist with Plex
I wanted to export my playlists with Plex, I installed Export Tools and ended up with CSV files.
I looked around and couldn't find something to convert those to m3u. I did get a m3u8 file but it didn't work with my devices...
I made a quick python script to convert the csv to m3u...it's possibly useful to someone else...maybe.
options,remainder = getopt.getopt(sys.argv[1:], 'f:r:', ['filename=','root='])
for opt,arg in options:
if opt in ('-f', '--filename'):
filename = arg
elif opt in ('-r', '--root'):
root = arg
# convert time to seconds
return sum(int(x) * 60 ** i for i,x in enumerate(reversed(t.split(":"))))
with open(filename,'r') as csvfile:
# skip header
playlist = csv.reader(csvfile)
for song in playlist:
print "#EXTINF: %s,%s - %s" % (get_s(song),song,song)
print "Error opening CSV file"