If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

[Rel] Import/Export M3U Playlists into/from a Plex Server

hilbertglmhilbertglm Posts: 2Members, Plex Pass Plex Pass

I have developed some Java code that will allow for the export of playlists in a Plex database to M3U files in a directory. The utility code will also import M3U files to a local or remote server without requiring direct access to the database file. Thus, it should work for importing to Synology or embedded systems, but I don't have such as system for me to test that.

There is no warranty or guarantee, so please backup your system appropriately before running any of this code.

To install and configure:

  1. Download and unzip the attachment into the directory of your choice.
  2. Create a file called credentials.properties and place this in the directory ".hilbert/plex-utilities" under your home directory. The contents should contain your Plex userid and password in the format described later in the post. For Linux users the full file name would be '~/.hilbert/plex-utilities/credentials.properties'. For Windows users the home directory is %HOMEDRIVE%%HOMEPATH%, so the full file name might look something like "C:\Users\glm\.hilbert\plex-utilities\credentials.properties" where glm is my Windows login name.
  3. In the directory into which you unzipped the attachment, there will be a file "resources/META-INF/solutions.abelian.core.jdbc.ConnectionConfiguration.properties". That file needs to be edited to reference the SQLite database for the Plex database.

The credentials.properties file should contain two lines of the form:

userid=yourPlexUsername
password=yourPlexPassword

To run the code, change directory into the directory into which you unzipped the downloaded code and run the 'cli' script for the command-line interface. There is a 'help' command. The 'import' and 'export' commands will be the ones of interest, so 'help import' and 'help export' will give more explanation. I have not created a Windows shell or PowerShell script, so someone will have to convert the bash script into equivalent for Windows.

If you don't want to set up the credentials.properties file, you can specify the credentials with the --user= and --password= options on the 'import' command line.

Typically the code can figure out the section where the playlists belong, but if you set up libraries with non-standard names, you may need to set the 'section' environment variable. The sections can be listed with the 'sections' command and the environment variable is set as in the following example:

set section Music

Note the lack of an '=' sign in the command. Substitute 'Music' for the section containing your music files as indicated in by the output of the 'sections' command.

Let me know if there are any issues with the code, and let me know if it was useful for you.

Comments

  • akreaxunakreaxun Posts: 16Members, Plex Pass Plex Pass

    "Download and unzip the attachment into the directory of your choice." --> I guess on the computer on which you are running PLEX.

    Handing out credentials to a program of which I don't exactly know what it is doing - seems a bit risky...

    sorry there's got to be another way.

  • martin@zeichner.usmartin@zeichner.us Posts: 7Members, Plex Pass Plex Pass

    Hi there hilbertglm,

    I came across your post because I am interested in importing and exporting m3u playlists to and from plex.

    I am not a programmer and I only have a very limited understanding of Java so please forgive me for being dense. I am stuck on number 3 of "Install and configure"

    I have the file but I am uncertain about how to edit it as per your statement "That file needs to be edited to reference the SQLite database for the Plex database."

    1. connection.plex.name=plex
    2. connection.plex.url=jdbc:sqlite:/home/glm/develop/java/hilbert/applications/plex-utilities/com.plexapp.plugins.library.db
    3. connection.plex.driver=org.sqlite.JDBC
    4. connection.plex.database=/home/glm/develop/java/hilbert/applications/plex-utilities/com.plexapp.plugins.library.db
    5. connection.plex.host=jobim.hilbertinc.com

      I assume that I must edit lines 2, 4, and 5 but I am uncertain about how to proceed. Any help that you might give would be appreciated. Thanks in advance.

  • dane22dane22 Posts: 10,848Members, Plex Pass, Plex Ninja Plex Ninja

    Next, and not yet released version of WebTools will be able to do this
    Expect a public Beta within the next 3-4 weeks, so stay tuned to the WebTools support thread

    /T

    I hate bugs - Tommy Lee Jones, MIB
    Join me in developing: epg-dk, str2utf-8, remidx, ExportTools, WebTools
    Support the Samsung Client:Donate
    Guides I use: Media Naming Guide, Local subtitles, Log-Files, QNAP FAQ, The Plex Dance

    NO Support via PM, unless called by me

  • mbarylskimbarylski Posts: 572Members, Plex Pass Plex Pass

    @dane22 said:
    Next, and not yet released version of WebTools will be able to do this
    Expect a public Beta within the next 3-4 weeks, so stay tuned to the WebTools support thread

    /T

    Has there been any progress on a WebTool version that can import m3u playlists?

  • dane22dane22 Posts: 10,848Members, Plex Pass, Plex Ninja Plex Ninja

    Still in development sadly, and when released, we'll start by import of webtools generated playlists only, since highly complicated.

    Current beta status regarding playlists are, that we can delete, copy among users, and export.

    to participate in the beta, see the pinned post

    /T

    I hate bugs - Tommy Lee Jones, MIB
    Join me in developing: epg-dk, str2utf-8, remidx, ExportTools, WebTools
    Support the Samsung Client:Donate
    Guides I use: Media Naming Guide, Local subtitles, Log-Files, QNAP FAQ, The Plex Dance

    NO Support via PM, unless called by me

  • mbarylskimbarylski Posts: 572Members, Plex Pass Plex Pass

    @dane22 said:
    Still in development sadly, and when released, we'll start by import of webtools generated playlists only, since highly complicated.

    Current beta status regarding playlists are, that we can delete, copy among users, and export.

    to participate in the beta, see the pinned post

    /T

    Ok, thanks. Don't know why but I can't find this pinned post. All I see at the top is the first message about the tool that was not using WebTool. Can you send me the link?

  • dane22dane22 Posts: 10,848Members, Plex Pass, Plex Ninja Plex Ninja

    I hate bugs - Tommy Lee Jones, MIB
    Join me in developing: epg-dk, str2utf-8, remidx, ExportTools, WebTools
    Support the Samsung Client:Donate
    Guides I use: Media Naming Guide, Local subtitles, Log-Files, QNAP FAQ, The Plex Dance

    NO Support via PM, unless called by me

  • beelymageebeelymagee Posts: 2Members

    dane22 - just curious about this error when trying to use WebTools (just downloaded and set up on XUbuntu box) - trying to import any of my existing M3U (or PLS) playlist files into Plex via the WebTools:
    Technical Info:
    Url: api/v3/playlists/Import
    Location: Playlist
    Error: playlistService.importPlaylist - Aborted, since not our playlist

    It appears that the IMPORT feature is not working yet? Or, another playlist file type needs to be supplied? Maybe an .XSPF file or XML file? Really hoping I don't have to recreate all of the playlists I use, I'm liking what I see so far as a replacement for TwonkyServer.

    -*-Bill

  • beelymageebeelymagee Posts: 2Members

    I guess that Plex is very iTunes-centric! I keep seeing references in the forums while searching for playlist import that importing M3U files is not supported at this time, only iTunes exported playlists. I'm running Linux so that might be a tough one - I might be able to cobble together the iTunes playlist as exported on a Mac, massage the data so the directory structure matches what I have on the Linux box. Seriously surprised that this import functionality is NOT built in to Plex and the WebTools plugin doesn't appear to support M3U or PLS.

    -*-Bill

  • dane22dane22 Posts: 10,848Members, Plex Pass, Plex Ninja Plex Ninja

    @beelymagee

    In this first release of the Playlist module, we only support import of our own exported lists

    https://github.com/ukdtom/WebTools.bundle/wiki/Playlists#import-a-playlist

    I hate bugs - Tommy Lee Jones, MIB
    Join me in developing: epg-dk, str2utf-8, remidx, ExportTools, WebTools
    Support the Samsung Client:Donate
    Guides I use: Media Naming Guide, Local subtitles, Log-Files, QNAP FAQ, The Plex Dance

    NO Support via PM, unless called by me

  • random72guyrandom72guy Posts: 2Members, Plex Pass Plex Pass

    @dane22 When do you expect to release support for third party playlists? And would automatic import be supported (rather than manual importing via the UI?)

  • dane22dane22 Posts: 10,848Members, Plex Pass, Plex Ninja Plex Ninja

    @random72guy

    I never give out an ETA, sorry

    And automatic import is not to be expected in a long time.

    I hate bugs - Tommy Lee Jones, MIB
    Join me in developing: epg-dk, str2utf-8, remidx, ExportTools, WebTools
    Support the Samsung Client:Donate
    Guides I use: Media Naming Guide, Local subtitles, Log-Files, QNAP FAQ, The Plex Dance

    NO Support via PM, unless called by me

  • jpg_musicjpg_music Posts: 5Members ✭✭

    I'm trying to use the hilbertglm script on linux (rasberrypi) but I get the following error when trying to export a playlist:

    Error running 'export'
    com.hilbertinc.framework.commons.command.processor.CommandExecutionException: The connection name could not be determined. You need to set the 'connection' environment variable with the 'set' command

    Any help of how to fix this and what to set 'connection' to would be appreciated.

    thanks

Sign In or Register to comment.