Import Playlists into Plex on macOS

From Software Wiki
Jump to navigation Jump to search

Source: https://www.reddit.com/r/PleX/comments/ecirqa/how_to_manually_import_an_m3u_playlist_into_plex/

Note: Adding macOS-specific instructions

Assumptions

  • Music.app is running on a macOS device: Daily Driver.
  • Plex Media Server is running on a different macOS device: Server.
  • File structure for both Music.app and Plex media files are similar.

Instructions

Preparation

On my daily driver, a MacBook Pro, I have curated playlists and smart playlists for many years, and have set up Music.app to keep my music organized in folders by artist, album, and track title:

/Users/robertallred/Music/iTunes/iTunes Media/Music/Garth Brooks/Garth Brooks/10 The Dance.m4a

I use a Hazel script to move new music to my server three days after it is added to Music.app. This gives me time to correct any metadata issues before it gets moved over.

The file path for the Plex music library on my server is different (since it's on an external drive), but follows the same structure as the MBP: artist, album, track title:

/Volumes/Media/Media/Music/Music/Garth Brooks/Garth Brooks/10 The Dance.m4a

Daily Driver

In Music.app, select the playlist or smart playlist you wish to export. In the File menu, select Library and then Export Playlist....

In the dialog box, select a name and location to save the playlist. Make sure it is a location that is accessible by your Plex Media Server, I save it to the Desktop of my server.

From the Format dropdown menu, make sure to select M3U.

Open the new playlist file in your text editor of choice, I use BBEdit. Do a find and replace of the pathnames so that they match the file structure of the music in your Plex music library:

E.g. using the example from above of /Users/robertallred/Music/iTunes/iTunes Media/Music/Garth Brooks/Garth Brooks/10 The Dance.m4a you would do a find and replace like:

Find: /Users/robertallred/Music/iTunes/iTunes Media/Music/

Replace All: /Volumes/Media/Media/Music/Music/

Once the find and replace has completed successfully,

Server

This section was originally written by u/KarmicCamel over on Reddit back in 2019. I've made some edits to their original instructions.

  1. Open your Plex server web app, as you normally would. I usually go to plex.tv and log in, then click the Open Plex button.
  2. In Plex, navigate to any file in the library for which you want to import a playlist (e.g. in your Music library, navigate to '10 The Dance.m4a').
  3. On the play bar for that library item, click the More Actions ellipses ..., select Get Info, and then click View XML.
    • A new browser window opens containing XML details about the library item.
      • From the URL, copy the X-Plex-Token value into a text editor.
      • From the page content, copy the librarySectionID value into a text editor.
  4. Download Postman. You can use any tool that can send HTTP requests, but in this guide, I'll be using Postman.
  5. In Postman, create a new request from the File menu.
    • In the modal popup, select HTTP
    • If you want to save your request, click the Save button. In the subsequent dialog box, give it any name and save to any collection, then click Save. The name and collection don't matter, this is just how Postman organizes things.
  6. In your new Postman request, select or enter the following details:
    • Left-hand drop-down menu: Select the POST option.
    • Enter URL field: Enter the following URL, replacing bracketed items as directed.
    http://[PlexServer]:32400/playlists/upload?sectionID=[librarySectionID]&path=[PathTo.M3U]&X-Plex-Token=[Token]
    Where:
    • [PlexServer] is the IP address of your server running Plex Media Server. If you're hosting the server on the same machine as you're running Postman, this will likely be 127.0.0.1
    • [librarySectionID] is the librarySectionID value you noted in step 3. This will be a number, like 5
    • [PathTo.M3U] is the full path to the .m3u file you want to import from the perspective of the Plex Media Server. For example: /Users/robertallred/Desktop/Country.m3u, if the .m3u file is on the Desktop of the server running PMS. If you have it on your local device, adjust the link appropriately.
    • [Token] is the X-Plex-Token value you noted in step 3. This will be a string of randomized characters. This token may expire, so in the future, you may need to repeat step 3.
    A properly formatted URL should look something like the following:
    http://127.0.0.1:32400/playlists/upload?sectionID=5&path=/Users/robertallred/Desktop/Country.m3u&X-Plex-Token=abC4eF6gG78hIj9KlM10
  7. Ensure that Plex Media Server is running on the server. If it is not running when you send your request, you will get a "Could not get any response" error.
  8. Leave all other settings at their defaults and then click the Send.
  9. If you have Plex open on a device or in a browser, refresh.

If all goes well, you should now see the imported playlist in your Plex server web app.