Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

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.

#!/usr/bin/env python

import csv
import getopt
import sys

options,remainder = getopt.getopt(sys.argv[1:], 'f:r:', ['filename=','root='])

root=''
for opt,arg in options:
    if opt in ('-f', '--filename'):
        filename = arg
    elif opt in ('-r', '--root'):
        root = arg


# convert time to seconds
def get_s(t):
    try:
        return sum(int(x) * 60 ** i for i,x in enumerate(reversed(t.split(":"))))
    except:
        return 0

try:
    with open(filename,'r') as csvfile:
        # skip header
        next(csvfile)
        playlist = csv.reader(csvfile)
        print "#EXTM3U"
        for song in playlist:
            print "#EXTINF: %s,%s - %s" % (get_s(song[9]),song[3],song[5])
            print song[-1][len(root):]
except:
    print "Error opening CSV file"
    sys.exit(1)

Wordpress category: 

Add new comment

Markdown

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.