Can Plex import playlists?

1 minute read

So I have been using Plex as my media server for over a month now and it just drives me crazy that I cannot import my playlist from MediaMonkey. I started looking for a solution and finally found one, a python script I could run to fix it!

To Resolve:

  1. Newer version [Plex can be running].

    1 2 3 4 5 6 7 8 9 10 11 cd /home/gerry yum install git -y # clone repo git clone //github.com/dakusan/PlexPlaylistImporter.git cd PlexPlaylistImporter/ # run script that imports '/mnt/music/playlists/5-star-trance.m3u' to playlist called 'trance' chmod +x ./PlexPlaylistImporter.py ./PlexPlaylistImporter.py -p /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db /mnt/music/playlists/5-star-trance.m3u trance

    1 2 success 134 items added

    1 2 ./PlexPlaylistImporter.py -p /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db /mnt/data/data/my-music/linux-playlists/z-rock-n-roll.m3u z-rock-n-roll ListImporter 'Winamp playlist': Cannot find file listed in playlist [must be relative to the playlist]: ../music-library/acdc--back-in-black.mp3

    • The fix is to go to your music library and make sure that file exists with that name.
  2. Older version of this article:

    1 2 3 4 sudo yum install epel-release sudo yum install python34 curl -O //bootstrap.pypa.io/get-pip.py sudo /usr/bin/python3.4 get-pip.py

    • When I ran the script, it asked me for the full media library path. According to the guide I was able to find it at:

    1 /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db

    • I then had to point it to my media library path where the .m3u files were:

    1 /share/my-music/my-playlists/playlist-name.m3u

    • Lastly, since I use Windows, I had to convert \ to /

    1 2 3 4 sudo pluma playlist-name.m3u # find and replace Ex: [Navigate to script dir] ./PlexPlaylistImporter.py -p /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db /my-share/my-music/my-playlists/dubstep.m3u

    • If you get the error DB Error: unable to open database file try prefacing the command with sudo.

Tags: MediaEditing

Categories: LocalSoftware

Updated: 2016-12-24

Twitter Facebook LinkedIn

Plex Playlist Importer - v1.1.0.x //www.castledragmire.com/Projects/Plex_Playlist_Importer

My music directories have been growing for over 2 decades in a folder based hierarchy, often using playlists for organization. Plex’s music organization is counterintuitive to this organizational structure, and Plex currently does not have an easy way to import external playlists. Hence this script was born :-]

You can run this by directly dragging playlists onto it.
This script is fully unicode compliant.

##Running and Troubleshooting

  • While this script requires Python 3 [compiled against v3.4], a stand-alone Windows binary version is also available on the URL at the top of this file.
  • While running the windows executable, if you get an error of “The program can't start because MSVCR100.dll is missing...”, download the “Microsoft Visual C++ 2010 Redistributable Package [x86]”.
  • If running through the Python source, The Python sqlite3 lib is required, but it should come with Python.
    • If running this mentions something about “no such module : FTS4”, you may need to replace the sqlite3.dll or sqlite3.so for your Python, which can be found at //www.sqlite.org/download.html .
      • For a Python for Windows install, the DLL location will most likely be located at one of the following locations:
        • C:\Python%PYTHON_VERSION%\DLLs
        • C:\Program Files [x86]\Python%PYTHON_VERSION%-32\DLLs
        • C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python%PYTHON_VERSION%\DLLs

##Parameters: usage:
PlexPlaylistImporter.py [-h] [-p Given_DB_Path] [-e Playlist_Encoding] [-t File_Type_Override] [-f] Playlist_Path Plex_Playlist_Name

positional arguments:

ArgumentsExplanation
Playlist_PathThe path of the playlist file
Plex_Playlist_Name The name of the playlist in Plex to import to.
  • If not given, the program will prompt for it.
  • If the given playlist does not already exist, the program will prompt on whether to create it [unless -f is specified].

optional arguments:

ArgumentsExplanation
-h OR --help show this help message and exit
-p OR --sqlitedb-pathGiven_DB_PathThe path to the sqlite3 database file
  • The program tries to guess the path for the Plex data directory. If it cannot be found, this path needs to be passed explicitly
    • The default paths are:
      • Windows:
        • %LOCALAPPDATA%/Plex Media Server/
        • C:/Users/%USER%/AppData/Local/Plex Media Server/
      • Linux:
        • %PLEX_HOME%/Library/Application Support/Plex Media Server/
  • If the database is still not found from the given Plex path, the full path to the database is required
    • Defaults: [%PLEX_PATH% is from the path found from above]
      • %PLEX_PATH%/Plug-in Support/Databases/com.plexapp.plugins.library.db
      • %PLEX_PATH%/Plug-Ins/Databases/com.plexapp.plugins.library.db
    • Note: When passing a parameter string, environmental variables are not processed
-e OR --playlist_encodingPlaylist_Encoding The encoding the playlist file is in. This is generally “utf-8”, but may also likely be “ISO-8859-1”. Default=utf-8
-t OR --override-typeFile_Type_Override The file type to encode as. If the file extension is not recognized, the file is parsed as a Winamp playlist [m3u]. This allows overriding the determined file type. Default=NONE
-f OR --force-list Do not prompt to create the playlist if it does not already exist.

The only playlist type that is currently supported is Winamp playlists [.m3u].
Playlist importers just collect the absolute files names, and others can easily be dropped into the “Importers” directory without any other code changes.
While the M3U importer [Importers/M3U.py] is the most appropriate to use as a template, I included a second example one [PTL.py] which just pulls in absolute file names with no error checks.

PlexPlaylistImporter.sh is just included to force proper Unicode [utf-8] encoding and column widths on the console.

##How it works The songs you want to play have to already exist in the Plex database.
When you add a song to Plex [through Plex], it stores the song’s full file path in the Plex database. What this script does is derive all the full song paths in a playlist file that you give it, checks those paths against Plex’s database, and then adds the matches in the proper order into the Plex playlist you specified.
So for this reason, the script must be ran on the same computer running the Plex server so that it can match the paths. [There are, of course, workarounds to this. However, I highly recommend against it, as I have found that doing this may corrupt the Plex server database].

##Creating the executable python setup.py py2exe

Copyright and coded by Dakusan - See //www.castledragmire.com/Copyright for more information.

Video liên quan

Chủ Đề