Option to use existing m3u for playlist feature

I’m jumping up and down too! I can’t believe requests for a feature this basic aren’t being acknowledged or acted on. Glad I didn’t plunk down cash for Plex, I don’t need the premium features but wouldn’t mind contributing if it met my needs in other ways (M3U Playlist importing on Raspberry Pi WITHOUT iTunes).

1 Like

I’ve been waiting for this for ages now!
Emby has it figured it out already, but its Alexa skill is bad and won’t work with the free version. And I don’t wanna go back to Emby and buy the premiere version of it.
Plex NEEDS to get on board on this.
The music side of the server is extremely useful!

For what it’s worth, I’ve been able to successfully import all of my 100s of external m3u playlists into Plex via iTunes and it works…sort of. To be clear, I’m not using iTunes for anything other than a means to get my playlists imported into Plex. The only problem remaining for me is Plex’ lack of playlist synch/update. I read somewhere on this forum that it was never meant to do that and that the external playlist import was for a one-time import only, with the assumption that users will manage their music playlists in Plex after that, which to me is a non-starter. So currently, the only way for me to update my music playlists in Plex is to delete them all and do a complete rescan, which takes hours. I’ve posted this in the new feature request section, let’s see what happens.

1 Like

Wow, this thread started five years ago, and still this extremely simple function has not been implemented? I’ve used Squeezecenter duets for over 12 years but my duet receivers and are dying off and no longer easy to replace, so I’m forced to try Sonos. However, without the ability to import my dozens of .m3u playlists, there’s really no point. Very disappointing.

3 Likes

Can we please try to push this up again?
I am finding so frustrating to see Emby dealing with playlists so much better but I bought a Plex pass for all the other good reasons and this is the one thing that I really wanna see happening so I can go aahhhh :slight_smile:

So, let’s try to bring it up? I do believe this should be very simple.

Please, Plex guys? Full .m3u handling?

Thanks for mentioning Emby, I was not aware of it. Knowing now that there is an alternative to Plex that is able to properly handle m3u playlist import and sync, I will do more research, weigh my options and potentially switch, because I am no longer willing to pay for my Plex pass without having that feature.

part of the problem with m3u playlists is the path

PMS runs as a server, and may have a completely different path to the same music files that another app created the m3u with.

not only in the whole windows/vs linux “/” vs “” change, but also whether the playlist is full path or some type of relative path.

all that said, these types of issues are not insurmountable.

Emby figured it out.

1 Like

I’m not a huge fan of m3u’s since they’re a bit of a legacy thing from the old world of files and folders (with precisely the problem mentioned above, filepath issues, broken links if the underlying file gets moved/renamed, etc) and we should ideally move towards a purely metadata-driven system, but if there’s enough support then sure why not. Browse-by-folder also made it in, after all.

what playlists support means, is being able to more easily import/export information to/from plex.

meaning you can have a playlist of each rating, or genre, or whatever, that can then be matched up in plex, or exported for use outside of plex.

There’s a free program, List Fix (for Windows) that can find and automatically fix path issues in M3U Playlists, works great, I’ve been using it for years. Really wish Plex would get this simple feature added in the web interface or server. Seems like such a simple request to be sitting on the table for 5 years. I’d gladly buy a Plex Pass if they implement this simple feature. Come on guys, show the Music people some love…PLEASE…

2 Likes

+1 - been waiting for this for years. I have successfully used the Python script, but it’s a bit cumbersome.

Exactly. It’s so upsetting not seeing the same being implemented on Plex (speaking as a Premium user)

I was able to build a Plex music playlist from a .M3U file by using the https://python-plexapi.readthedocs.io/en/latest/introduction.html libraries and Python 2.7. (There are probably a lot of ways to do what I did — I’m neither a Plex expert nor a Python expert — but I did get it to work.) I have more than 18,000 songs in my music library, and more than 800 in my “favorites” .M3U file. Manual playlist setup was not an option. I like this new Plex setup because I can use Fire TV to play what certainly sounds like my CD-quality audio and to show the Plex Pass lyrics. (I watch video using NVIDIA SHIELD, but Plex Pass lyrics only work intermittently on that box when listening to audio, so I use Fire TV (only) for audio.) I could copy some code in here if anyone’s interested. [EDIT: Actually, Plex Pass lyrics don’t work reliably well on Fire TV either. It shows for some songs that LYRICS are available, but they fail to load. Very frustrating.]

1 Like

@rvatalaro, this would be amazing! I’ve never used Python, so would need your help with some form of “how-to”. Also would be good to understand how you structured your m3u file (anything in besides file names? file structure //folder or \folder or whatever else?).

FYI if relevant, I am running Plex on docker on Unraid.

Thanks a lot!!! I am in a similar situation to you and playlists are preventing me to make the full switch to Plex for music.

OK, I’ll prepare a message and upload it soon. Keep in mind, however, that I am neither a Plex expert nor a Python expert. I am sure there are better ways to do what I did. But I will show you what I did. I don’t see why it wouldn’t work for you. And while I’m writing this, keep this in mind: you will need to install Python (see python.org). I have three versions installed (one 2.x and two 3.x versions). My current 2.x is 2.7.16, so I know what I show you will work with that version. Also, it requires the PlexAPI (see URL in previous message). Once you install Python, do “pip install plexapi” (as told in the PlexAPI documentation). However, if you try to do something and something like “cannot find mock” or something like that shows up, just do “pip install mock” for Python 2.x.

The format of my files and directories are worth mentioning, since you will likely need to tweak my code with your setup. My .M3U files are as you would expect: one file per line. How I prepare it takes some explaining. My audio library is based on .WAV files. .WAV files (currently) have no metadata like, for example, .MP3 files. So I programmatically convert the .WAV files to .FLAC files; attach the metadata; and then give them to Plex. It is easy to add the music files, since I just point Plex at the top-level directory. Making a playlist from a .M3U is, of course, more. The .FLAC files live in a directory called xxx/Pure FLAC. The xxx just represents anything “above” where I store the music (higher-level directories). You will need to know what your xxx is to use my code. (Actually, in my code, since I was just testing to see if it worked — and it did — I left the kludge that I first put in: I just stripped off the number of characters I knew were in the prefix. I’ve been programming a very long time, and I wouldn’t code this way other than quick-and-dirty. Whatever.) To the right of Pure FLAC (i.e., lower-level directories) are artist/album/##-song.FLAC. The ## is the track number of the CD (album). Now, from memory (until I look at the code again), this path is NOT all that important. What IS important is its uniqueness (as it will be used to form a key, like a primary key in SQL). In my naming scheme, it’s pretty clear this “key” is unique. That’s important.

Once you’ve added your music to Plex, you can study the code I provide in my next message, but there’s a way to find out the path of each song you’ve added. In my case, the path in the .M3U is actually NOT the same as the path I use to import into Plex. In other words, the yyy in the .M3U file does not match the prefix xxx in the paths to the music. But all my music is stored (for the purposes of Plex) in the same top-level directory. Anyway, my playlist entries all start with yyy and the paths in Plex start with xxx They do not match. That is why I had to create a key to identify each song. See key above. It uniquely describes the song, no matter where it is in the hierarchy. Once I read in the line of the .M3U file, I convert it to a key. I also load all the music from Plex, and build keys from those Track records. After that, it’s a simple matter to add the tracks to the Plex playlist. I call my playlist z9 (for historical reasons). Now, it should be possible to create a playlist (holder) using the PlexAPI, but I just created it in the web interface. I filled it with tracks, however, with Python. I will post a message soon with the code.

There is also a Plex web API that is documented. I plan on studying that. Maybe this playlist thing would be trivial with that. Some months ago I was studying Python and the Python PlexAPI so I could read the Plex database, but I stopped when someone pointed out ExportTools. I have my video pretty much done, so now I am back to working on audio, and that seems to require more programming.

Also, FWIW, I am not “@rvatalaro” anywhere that I know of. Do not confuse my forum ID here with any other forum or social-media presence.

1 Like

OK, here’s some code.

from plexapi.myplex import MyPlexAccount
account = MyPlexAccount('username','password')
plex = account.resource('LAN1').connect()
music = plex.library.section('Music')
playlists = plex.playlists()

That is how I would open a session in Python using the Python PlexAPI for working on audio. LAN1 is the name of this particular PMS. Next, I create a function that reads the music library and creates “keys” for each entry.

def build_fkey2tr():
  global fkey2tr
  fkey2tr = {}
  for tr in music.searchTracks():
    fkey = tr.media[0].parts[0].file[29:].upper()
    if fkey in fkey2tr:
      print "fkey2tr ERROR:",fkey,"for",tr,"was",fkey2tr[fkey]
    fkey2tr[fkey] = tr
  print len(fkey2tr), "tracks."
  print "First 3:",fkey2tr.keys()[0:3]

build_fkey2tr()

I tend to use TAB for indention. I changed to two spaces here. To get the code to “look good” in the post I had to use a combination of the BLOCKQUOTE and PREFORMATTED TEXT functions. The file[29:] stuff is where I strip off the xxx as mentioned in my previous message. Quick-and-dirty, like I said. Next, well, look at the code.

z9=plex.playlist( 'z9' )

#pl = []
def updpl(plexpl,f):
#  global pl
  pl = []
  with open(f, 'r') as m3ufile:
    cnt = 0
    cntpl = 0
    for fname in m3ufile:
      cnt = cnt+1
      fkey = fname[9:-1].upper()
      if fkey in fkey2tr:
        cntpl = cntpl+1
        tr = fkey2tr[ fkey ]
        pl.append( tr )
        z9.addItems( tr )
      else:
        print "fname=",fname,"fkey=",fkey,"has no fkey2tr"
#      if cnt > 5:
#        break
    print cnt, "lines in M3U file."
    print len(pl),"(",cntpl,")", "tracks in playlist."
    print "First 3:",pl[0:3]

updpl( z9 , '\\\\...\\Playlists\\z9.m3u' )

There you have it. The fname[9:-1] is where I strip off the yyy and the trailing “\n”. Like Perl, Python converts input CRLF to LF ("\n"). So (quick-and-dirty) I just stripped off the last character.
This is all not rocket science. I’m sure you’ll figure it out. I’ll check back later to see if there are any questions.

NOTE: Obviously the pl variable is more or less not needed. You can see it’s partially commented out. However, I wonder if there’s a Plex expert out there actually reading this. If so, would it be better to build pl and then call addItems once (for all in pl), or one at a time (tr) like I’m doing now (in my first attempt — which worked!). Since it’s basically a one-time thing, it’s not all that important. But I figured I’d ask.

1 Like

.XSPF provides more metadata than .m3u playlists, i.e. ratings. So I would like to see it included as well.

1 Like

I would welcome this for the simple fact that it could be used as an override for stubborn folder scans. I had to move Adam-12 out of my default library, remove the Plex entry, and move back for a new scan. I’m sitting here twiddling my thumbs while VLC built & saved my list and is playing.

1 Like

Yes, the lack of a properly working metadata rescan is annoying.

1 Like