alistairphillips.com

I’m : a web and mobile developer based in the Australia.


Import iTunes/Apple Music into Plex

On the 4th July 2020 I finally managed to migrate my Apple Music/iTunes library from macOS to Plex. It took me an absolute age to figure out, with many a false start. I'm hoping that these steps will help anyone else. Of course YMMV as every set up is different.

Most of this was based upon posts at https://forums.plex.tv/t/how-to-sync-itunes-playlists-to-plex-on-a-mac/511231 and https://www.npmjs.com/package/plex-itunes-import/v/0.1.1. In the interests of speeding up testing I initially only copied a single file. This way I was able to quickly try changes without having to wait for my entire 5000+ item library to import.

Prepare your XML file:

Apple Music can generate an XML file from your library. This XML file will contain references to all of your media, along with important metadata such as play count and ratings.

In my case my XML file was called iTunes Library.xml, and all of my media was in /Users/alistair/Music/iTunes/iTunes Media/Music.

My Plex server is running on a Synology NAS, with a media path of /volume1/Media/Music/ for the music files.

You need to update file references in the XML file to point to the new location. Perform a search and replace in the XML file to change the Location element from file:///Users/alistair/Music/iTunes/iTunes%20Media/Music/_NSYNC/Celebrity/01%20Pop.m4a to file://localhost/volume1/Media/Music/_NSYNC/Celebrity/01%20Pop.m4a.

It seems that the localhost string in the new location is important - at least for Plex. I found this out from https://forums.plex.tv/t/importing-playlists-from-itunes/146877/36

Copy your music across:

Copy your existing media to the new location. It's important to retain the same folder structure so that files referenced in the XML file can be found. In my case I created a Music folder in my Plex media share and copied everything from ~/Music/iTunes Media/Music from macOS.

Plex set up:

Plex is able to able to populate its own internal library based off of the contents of your iTunes XML file. The only way I managed to achieve this was to:

At this point Plex will now import your iTunes library into a local database. I was able to spot this from the Console logs in Plex. Note that if Plex can't find a media file then it will skip importing the ratings and play count.

Music Library Creation:

At this point Plex has now imported the metadata from the XML file, and saved it to the local database. The next step is to actually create the Music Library.

The dialog notes that:

Importing from iTunes will import your music playlists. It will also import your ratings, the date you added the music, as well as play and skip counts for tracks in your library. Depending on how many tracks you have, this process can take many minutes to complete.

Once done that should leave you with a Plex music library containing your iTunes/Apple Music Playlists, Ratings and Skip Counts.