XBMC Sync Library

I have been running XBMC at home on an Apple TV for a while now. I have all videos stored on a server running Centos 5.5 with videos accessed over SMB. Recently I added another one however I wanted to make sure the libraries between the two stayed in sync. I also wanted to configure my PC with XBMC so that I could use that to easily manage my Libraries (Even with a universal remote it is a pain to do it on ATV’s)

These are the steps:

  1. On the server install Mysql
    [root@fs1 ~]# yum install mysql mysql-server
    [root@fs1 ~]# chkconfig mysqld on
    [root@fs1 ~]# /etc/init.d/mysqld start
    
  2. Next we need to setup a database and user for XBMC
    [root@fs1 ~]# mysql -u root
    
    mysql> CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL ON *.* TO 'xbmc';
    Query OK, 0 rows affected (0.00 sec)
    
  3. My Samba shares are configured like so
    [movies]
            comment = Movies
            path = /shares/movies
            public = yes
            writable = yes
            write list = peter,nobody
            guest ok = yes
            browsable = yes
            guest account = nobody
            security = share
    
    [tvshows]
            comment = TV Shows
            path = /shares/tvshows
            public = yes
            writable = yes
            write list = peter,nobody
            guest ok = yes
            browsable = yes
            guest account = nobody
            security = share
    

    We need to configure another share to store the thumbnails

    [xbmc]
            comment = XBMC
            path = /shares/xbmc
            public = yes
            writable = yes
            write list = peter,nobody
            guest ok = yes
            browsable = yes
            guest account = nobody
            security = share
    
  4. We now need to create an advancedsettings.xml file that XBMC uses to work out where the database is stored
    <advancedsettings>
        <videodatabase>
            <type>mysql</type>
            <host>192.168.1.20</host>
            <port>3306</port>
            <user>xbmc</user>
            <pass>xbmc</pass>
    	<name>xbmc</name>
        </videodatabase>
    	<pathsubstitution>
    	  <substitute>
    		<from>special://masterprofile/Thumbnails/</from>
    		<to>smb://192.168.1.20/xbmc/Thumbnails/</to>
    	  </substitute>
    	</pathsubstitution>
    </advancedsettings>
    

    For this to work with you you just have to replace the IP in the tag with the address of your Mysql server. You also need to replace the IP in the tag with the location of the share you have setup. Note I only use this for video if you also want to sync your music libraries you need to add

    <musicdatabase>
    	<type>mysql</type>
    	<host>192.168.1.20</host>
    	<port>3306</port>
    	<user>xbmc</user>
    	<pass>xbmc</pass>
    	<name>xbmc</name>
    </musicdatabase>
    

    This goes in the tag just like

  5. This advancedsettings.xml must be put on each device. This file is stored in the following locations
    Windows XP: Documents and Settings\<your_user_name>\Application Data\XBMC\userdata\advancedsettings.xml
    Vista/Windows 7: Users\<your_user_name>\AppData\Roaming\XBMC\userdata\advancedsettings.xml
    Mac OS X: /Users/<your_user_name>/Library/Application Support/XBMC/userdata/advancedsettings.xml
    iOS: /private/var/mobile/Library/Preferences/XBMC/userdata/advancedsettings.xml
    Linux: $HOME/.xbmc/userdata/advancedsettings.xml
  6. One of the XBMC is still running the native Apple TV OS so to add the advanced settings you need to ssh in. The default username is frontrow and password is frontrow. Unfortunately the only text editor installed is nano.
    bash-2.05b$ nano /Users/frontrow/Library/Application\ Support/XBMC/userdata/advancedsettings.xml
    

    Just copy and paste the contents of your advancedsettings.xml into nano and save it.

  7. The other XBMC is running CrystalBuntu so the advancedsettings.xml can be edited using vim. The default ssh username and password is atv
    atv@Crystalbuntu:~$ sudo vim /root/.xbmc/userdata/advancedsettings.xml
    

    Just copy and paste the contents of your advancedsettings.xml into vim and save it.

  8. On my windows PC I just copied the advancedsettings.xml file to c:\Users\Peter\AppData\Roaming\XBMC\userdata\advancedsettings.xml where Peter is my username.
  9. Once that is all setup you just need to reboot your ATV’s for the settings to take effect. On the Windows PC I setup my libraries and they and the cover art are now on all my devices.

Further Reading