Running a headless raspbmc media server on Raspberry PI

I’ve been banging my head with this for a few days now and finally got it to work, so I thought I’d share, as documentation about it is quite sparse.

The idea was to use my Raspberry PI as a headless media server. Headless as I don’t have a TV, so I’d use it mainly for listening to music.

Step 1: Install raspbmc on my Raspberry. That went smoothly.
Step 2: Connect the external HDs where my music is stored to the Raspberry PI. These get mounted automatically under /media/ with raspbmc.
Step 3: Edit ~/.xbmc/userdata/sources.xml to add my music library:


<sources>
    <programs>
       <default pathversion="1"></default>
    </programs>
    <video>
        <default pathversion="1"></default>
    </video>
    <music>
        <default pathversion="1"></default>
        <source>
            <name>Musica</name>
            <path pathversion="1">/media//MYBOOK/Music</path>
        </source> 
    </music
    <pictures>
        <default pathversion="1"></default>
    </pictures>
    <files>
         <default pathversion="1"></default>
    </files>
</sources>

All looks fine and dandy, do a service xbmc restart and … NOTHING! All the googling did not help much either, as the documentation only describes how to add a source from the XBMC UI, which I didn’t have any access to.

A lot of swearing occured…

I then found this thread on the xbmc forums: http://forum.xbmc.org/showthread.php?tid=132919&pid=1263543#pid1263543. Ok, so it seems I can edit the database files directly!! Gooooood, I like that! Let’s go:


sqlite MyMusic32.db
insert into path('idPath', 'strPath', 'strHash') values (1, '/media/MYBOOK/Music', null);

So far so good, now how do I get the damn thing to scan for media???

JSON-RPC Api to the rescue!

A quick http://192.168.1.9:8080/jsonrpc?request=%7B%22jsonrpc%22%3A%20%222.0%22%2C%20%22method%22%3A%20%22AudioLibrary.Scan%22%2C%20%22id%22%3A%20%221%22%7D later (for those without an inbuilt URL Decoder {"jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": "1"}) , and my Raspberry is happily scanning my music files! Yeehaw, I deserve a beer for that!