Kodi Community Forum

Full Version: Update HTPC Library from Another Linux Computer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have a always on Ubuntu server at home. I would like this Ubuntu server to on a timely manner (according to cron job) to run a bash or python script that would.

1. Wake my HTPC via WakeOnLan
2. Update Video Library
3. Clean Video Library
4. Put the HTPC back on suspend mode

My HTPC works very well with when it comes to resume, suspend, wakeonlan, etc.

So I adapted a BASH script I found and came up with this ugly and crude solution that kind of woks
Code:
#!/bin/bash

## XBMC: Remotely Wake XBMC from Suspend, Scan Library and Suspends again using the JSON API

## Configure your XBMC RPC details here
XBMC_HOST=<MY_HTPC_IP_HERE>
XBMC_PORT=80
XBMC_USER=<MY_USER>
XBMC_PASS=<MY_PASSWORD>

## Wakes the HTPC
wakeonlan <HTPC_MAC_ADDRESS_HERE>
sleep 10

## Defines a function to pass RPC JSON requests to the HTPC
function xbmc_req {
  curl -s -i -X POST --header "Content-Type: application/json" -d "$1" http://$XBMC_USER:$XBMC_PASS@$XBMC_HOST:$XBMC_PORT/jsonrpc >/dev/null
}

## Scan the Video Library
echo -n "Scanning XBMC Library on HTPC ..."
xbmc_req '{"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}';
sleep 60
echo " done."

## Clean Video Library of non-existent items
echo -n "Cleaning  XBMC Library on HTPC ..."
xbmc_req '{"jsonrpc": "2.0", "method": "VideoLibrary.Clean"}';
sleep 40
echo " done."

## Suspend HTPC
echo -n "Suspending ..."
xbmc_req '{"jsonrpc": "2.0", "method": "System.Suspend"}';
echo " done."[/quote]

I use sleep to pause the script and wait for library completion. Can someone help me pointing out how I can perform tasks 2, 3 and 4 using pythong in a way that the JSON requests actually wait for the finish of Library update using VideoLibrary.OnScanFinished?

I tried this piece of code without success

http://forum.kodi.tv/showthread.php?tid=...pid1366707

Thanks upfront for any help given.