Migrating from iTunes - some thoughts / tips

Hello,

Over the past few months I’ve been assessing Plex as a viable music-only alternative to the iTunes library / sync system that I’ve been using for years. IMO Apple has made iTunes increasingly clunky and the iOS app now resembles more of a shop-front for Apple Music than the decent music organiser / player that it used to be.

However, iTunes offers a few features that are in fact very useful. Notably the smart playlists are great for people like me with large music collections, and I also like to combine this with the “loved” track feature.

My aim was to try and replicate as much of this functionality in Plex as possible.

Firstly, my library resides on a Synology NAS which I access on my Mac by using a Symlink so OSX sees the library as local. Apparently not recommended but I haven’t had a problem with this. The first challenge was to have Plex read this library correctly which was problematic in my case as the paths to media files contained in the iTunes Library.xml weren’t relevant to the machine that PMS was running on (the Synology itself in my case). I set my Synology to run a shell command every evening to correct for this:

sed -i 's/Volumes\/iTunes%20library/volume1\/iTunes%20library/' /volume1/iTunes\ library/iTunes\ Library.xml > /volume1/iTunes\ library/iTunes\ Library.xml

This command replaces all instances of the media file path “volumes/iTunes library” that my Mac sees with “volume1/iTunes library” that is relevant when PMS is running on the Synology. It’s ok to tinker with the iTunes XML as it’s regenerated each time you open and close iTunes.

Now that I could scan my library in correctly it was time to dig through the details….

I found that Plex was able to import some iTunes playlists, but not others. I spent some time trying to figure out what the criteria was and came up with the following:

Plex will import all STATIC playlists no problem.
Plex will import SOME smart playlists, and even implement their matching criteria in some cases, like “music added in the last…”.

  • match “All Media” must be ticked at the top of the smart playlist options, ticking “Music” or anything else will result in the playlist not being imported.
  • adding a subsequent “Media Kind” criteria is ignored.
  • adding a secondary condition will generally result in an empty imported playlist.
  • “loved” criteria does not work but “star rating” does, but a quirk on the iTunes side.

As mentioned above, I like to star/“love” particular tracks in my library which would otherwise be lost and have them in their own playlist. It was proving difficult to get my “loved” items into Plex as the info isn’t written to the id3 tag and Plex does not read the criteria from the iTunes XML. I decided to convert all of my “loved” tracks in iTunes to “5 stars” as I figured that Plex read that info in ok from the xml. The problem is that iTunes (for some reason) applies individual star ratings of tracks across whole albums, meaning that if a single track on an album is rated 5 stars, then the whole album is rated as 5 stars in Plex. This was a no-go for me so I decided to use another shell command to manipulate the xml:

sed -i 's/<key>Loved<\/key><true\/>/<key>Loved<\/key><true\/> <key>Rating<\/key><integer>100<\/integer>/' /volume1/iTunes\ library/iTunes\ Library.xml

This command searches for the “loved” criteria in the xml (which applies to single tracks), and replaces it with a “5 star” tag. I then got my 5 star rated tracks in Plex that I could add to a “5 stars” smart playlist in Plex.

So overall I managed to get a lot of my iTunes functionality into Plex. Whether the system as a whole is fast/functional enough to be worthy of music use on the go is another question. I’d quite like it if Plex had a lightweight music client for use on mobile devices as I feel this functionality suffers from being “bundled in” with the video options. I’m trying out Subsonic/Madsonic at the moment which seems to be snappier on the mobile side of things, but with limited developer interest/support.

Anyway, hope the above is of use to someone.

I’ve done some additional work with this relating to the way that Plex handles music videos. I want to keep my nicely sorted music videos which follow:
Root music directory > artist name > descriptive name > video file

This works well in iTunes and I don’t particularly want to change it. The only way to have Plex recognise the video files (and link to the artist in the music library) when they are sorted in this way is to have one of the artist’s mp3s in the same folder as the video file. This sounds very messy to me so I came up with a shell script to scan my iTunes music folders, find any video files and copy Symlinks of them into a correctly ordered “Music Videos” folder located elsewhere. This way, I can point Plex at this separate folder and it get scanned in and links to the relevant artists. I also get to keep my inline file ordering that works well in iTunes.

One gotcha, and this relates to my particular circumstances of having my iTunes library on a NAS is you have to make sure that the smb server honours symlinks. You can make a change to the smb.conf file on the Synology to achieve this.

Script below. I run this as a “scheduled” task on my Synology, so file paths relate to my particular circumstances. You can change this around to suit your own needs. Use at your own risk!

counter=0
cd /volume1/iTunes\ library/iTunes\ Music/Music

find . \( ! -regex '.*/\..*' \) -type f -name '*.mkv' -o -name '*.mp4' -o -name '*.wmv' -o -name '*.flv' -o -name '*.mov' -o -name '*.avi' -o -name '*.vob' -o -name '*.mpg' -o -name '*.mp2' -o -name '*.mov' | while read filename; do
	filename_target=`echo $filename | sed 's/.*\///'`
	filename_rootfolder=$(echo "$filename" | cut -d "/" -f2)

	while [ $counter -lt 1 ]; do # deletes and recreates the Music Videos folder. Only performes this once each launch.
		rm -rf /volume1/iTunes\ library/iTunes\ Music/Music\ Videos
		mkdir /volume1/iTunes\ library/iTunes\ Music/Music\ Videos
		counter=$(( counter+1 ))
	done
	
	mkdir -p /volume1/iTunes\ library/iTunes\ Music/Music\ Videos/"$filename_rootfolder" # creates artist directory if not already created
	filename=`echo ${filename#./}` # Removes first "." from file path - not sure if needed
	ln -s "$PWD"/"$filename" /volume1/iTunes\ library/iTunes\ Music/Music\ Videos/"$filename_rootfolder"/"$filename_target" # $PWD IS CURRENT DIR
done