iTunes Playlists in MythTV
May 14, 2008
I found a page a while back that had a perl script that imports your iTunes playlists into MythTV’s MythMusic. The MythMusic playlist editor isn’t a pleasure to deal with, plus if you already have all of your playlists set up the way you want them in iTunes, why not just synchronize your hard dragging and dropping? So the script on this page didn’t work at all for me, so it was time to hit the drawing board.
My setup goes like this: I have my iTunes Music folder on a portable terabyte drive which I periodically rsync using cgywin…
rsync -av –delete /cygdrive/f/iTunes Music/
root@mythbox:/share/Music/
Since iTunes renames files when you rename songs in their tags when you have that setting enabled, I leave it on and make sure I delete when I do the rsync, so that any files moved locally are just re-synced remotely.
Once the files are all there, in the same directories they exist in locally, I just rsync the iTunes Music Libary.xml file so that I can mine it for my playlists.
rsync -av –delete
/cygdrive/f/iTunes Music Library.xml
root@mythbox:/share/
Then periodically, you just have to scan for new music in the MythMusic settings interface and then run the PHP script.
It goes through the iTunes XML and gets all the information it needs (probably not the most efficient method, but whatever, RAM’s cheap) and then builds or re-builds the playlists in MythMusic.
The whole process takes a little while to complete and it will echo out all of the files it couldn’t figure out how to make work, but overall for my collection of 18855 it successfully maps 17982 of them, so it’s only missing my m4a files and some Björk.
Easy Installation Instructions
# cd /usr/src
# svn co
https://svn.tsnetworks.ca/weezey/itunestomythmusic/trunk
itunestomythmusic
Username is guest, password is blank
The resulting script can also be tossed into a cron job to be done automagically.
If you have any patches to improve the script they’re quite welcome and I’ll update the post, send them to mythmusic at weezey dot com.
Update 2009-04-21: I finally had a chance to commit the changes that James L sent me. The script runs a whole lot faster now and complains about life a whole lot less.
Tim, too much could be up, maybe try a PHP support channel on IRC.
Leave a Reply