I'd like to know how I can instruct Kodi to search for new (music) content only inside a particular directory via JSON-RPC. I have my Kodi (more specifically OSMC) installed on a Raspberry Pi 2 and my music is hosted on another system via Samba (another Linux machine; Banana Pi). Now and then I get new music and first tag the whole album utilizing beets on the Banana Pi. Then, after the music was placed into its destination folder I perform a JSON-RPC call to my Kodi machine using this command:
curl --data-binary "{\"jsonrpc\": \"2.0\", \"method\": \"AudioLibrary.Scan\", \"id\": 1}" -H "content-type: application/json;" http://$KODIHOST/jsonrpc
Now I know that I can pass a parameter directory
to the AudioLibrary.Scan command, but I don't quite know the correct syntax for that. When I only want one particular album folder to be scanned, what would the correct syntax look like? Should I pass it the physical path where the music lies on the music host (like smb://{HOST}/HDD1/Media/Music/Albums/{Album_Name}
) or rather use the virtual directory names that I have in my Kodi library (like Albums
, Compilations
etc.)?
I already tried it a few times with the smb:// prefix approach in different variations but it either wouldn't work at all or it would just scan the whole music library which takes quite some time.
Any advice on how to achieve what I want and whether it's possible to the granularity I'd expect is highly appreciated!
I just want to bring this to a close for posterity.
When I add new music to my network drive and organize it with beets, I also want it to show up in my Kodi media center. Now, issueing a AudioLibrary.Scan over Kodi's JSON-RPC API would rescan my whole music library which consists of tons of albums and could take up some while. What I needed was a way to tell Kodi to just scan that particular album or single - I know the path to that album after all since I just organized it.
Actually it was pretty easy since I was almost half-way there. All I had to do was adding an additional object named params
to the JSON-RPC call and within that passing the directory string. In this example, my music resides on HDD1/Media/Music/Albums on host BPI1 on my Samba network. So the path to my music that's configured in .kodi/sources.xml
on my media center looks like this:
smb://BPI1/HDD1/Media/Music/Albums
That's the path you'll want to take as the directory
argument for your RPC call and append the album name to it so that Kodi only scans that particular directory and nothing else. An example request for passing it via cURL could look like this:
{
"json_rpc": "2.0",
"method': "audiolibrary.scan",
"id": 1,
"params": {
"directory": "smb://BPI1/HDD1/Media/Music/Albums/Lenny.Kravitz-It.is.Time.for.a.Love.Revolution"
}
}
This would make Kodi scan Lenny Kravitz' album and spare out all the rest.
EDIT:
If you listen to lots of singles then just append the filename to your directory string and Kodi will only add this one song to your library. Like this:
smb://BPI1/HDD1/Media/Music/Albums/Lenny.Kravitz-It.is.Time.for.a.Love.Revolution/01-Love.Revolution.mp3