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:

       <default pathversion="1"></default>
        <default pathversion="1"></default>
        <default pathversion="1"></default>
            <path pathversion="1">/media//MYBOOK/Music</path>
        <default pathversion="1"></default>
         <default pathversion="1"></default>

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: 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 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!