[mythtv-users] itunes -> mythmusic syncing

Shanon Mulley shanonmulleyster at gmail.com
Mon Nov 21 17:51:38 EST 2005


Since I started using mythtv (and mythmusic), one of my biggest gripes
has been the clunky interface for creating playlists in mythmusic. Not
quite as elegant as the playlist editor included in itunes (which I
used before getting mythtv). I thought "wouldn't be cool if there was
some way of syncing the two? So I could manage my music on my windows
machine using itunes, then syncing it with mythmusic, so all the
songs, files and playlists were transferred automatically to
mythmusic?".

Eventually I decided to write such a script, and now I have decided to
share it with others (I'm sure I'm not the only one who has wanted to
sync mythmusic with itunes).

A few notes/assumptions/bugs:
1) This script assumes that all your music files (well, mp3's) are all
under one directory on your windows machine. You can have your music
organised in subdirectories within this, so long as they are all under
the one directory. This script in its current form wont work if some
of your music is in "d:\music\", and some is in "c:\music\"
2) I've only really tested this with mp3's. I think I specifically
target mp3's, and leave other files behind.
3) If a file or directory has some special characters in it, it wont
copy across. Special characters such as []() &' have been accounted
for, but some special characters wont - most notably pronunciations in
characters (like ā and ă). The output will tell you which files
failed. I just rename the files/directories.
4) I don't believe there are any special dependencies for this. Using
Fedora Core 4, perl and the xml parser were already installed. (Just
make sure they are installed).
5) While this script will copy across the playlists and music files
from itunes, it is not recommended you use this to copy across your
whole music collection. It will copy across each music file
separately, and this is very slow. For the first run, copy across your
music manually, and then run the scripts. After you add new music to
itunes, run the script again to update the few tracks you added.

Rough instructions:
I'm writing these instructions from memory - they might be a bit shaky.
1) Share the directories where you keep your music and itunes database
on your windows machine. They can be read only if you like. On my
machine, I shared "C:\Documents and Settings\username\My Documents\My
Music" as "mymusic", and "d:\My Documents\mp3" as "mp3". (This is
assuming your itunes database and your music are stored in different
locations)
2) mount the windows shares on your linux machine. If you don't know
what your doing, you'll probably have to edit your fstab file
(/etc/fstab on Fedora). I added the two following lines to my fstab
file:
---fstab start---
//free-snr/mp3  /mnt/mp3  smbfs username=username,password=password 0 0
//free-snr/mymusic  /mnt/mymusic  smbfs username=username,password=password 0 0
---fstab end---
3) On your myth machine, create a new database in the mysql database.
I called mine "itunes". I used the following lines to create the
tables/fields/keys necessary:
---mysql statements start---
create table Track (ID int, Name varchar(100), Artist varchar(100),
Location varchar(255), mythfilename text, mythintid int);
create table Playlist (ID int, Name varchar(100), PlaylistItems text);
alter table Track add primary key (ID);
alter table Playlist add primary key (ID);
---mysql statements end---
4) Give the mythtv sql user read/write access to the itunes database
(I forget the commands for that).
5) copy the three files (two scripts, one configuration file) onto
your linux machine, and make them executable ("chmod 755 filename.pl"
I think).
6) edit the itunes.conf file with your configuration info. I have
included instructions within the file to assist with this.
7) That's it! (I think)

Running the scripts
1) Run step1.pl (./step1.pl) (This populates the mysql itunes
database, and copies across the music files)
2) open up mythtv, run the "scan for new" function within mythmusic.
3) run step2.pl (./step2.pl) (This deletes all existing itunes
playlists [denoted with a (i)], and re-creates them all. NOTE - It
will not delete playlists you have created in mythmusic - it will only
delete those which have (i) in the playlist name).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itunes.conf
Type: application/octet-stream
Size: 1286 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20051122/46d41e80/itunes-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step1.pl
Type: application/octet-stream
Size: 9887 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20051122/46d41e80/step1-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step2.pl
Type: application/octet-stream
Size: 3445 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20051122/46d41e80/step2-0001.obj


More information about the mythtv-users mailing list