Kodi Community Forum

Full Version: [LINUX] Force library update and clear from console / cron?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, my XBMC is running 24/7 since my mediastation is also a router and a torrent box. So i never "start" xbmc but i also need to clean the library (removing erased files) and update new ones from time to time.

So my question is, is there any way to do this, say, every 2-3 hours? Is it possibile to issue this command via command line? Or using a python script?

Thanks.
Would really be great
Yes, a quick search would have brought up a few options.

Add a cron job with something like:

Code:
15    *    *    *    *    curl "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)" > /dev/null

more info at have a look at http://wiki.xbmc.org/?title=WebServerHTTP-API
prae5 Wrote:Yes, a quick search would have brought up a few options.

Add a cron job with something like:

Code:
15    *    *    *    *    curl "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)" > /dev/null

more info at have a look at http://wiki.xbmc.org/?title=WebServerHTTP-API

Good workaround but a native solution would be much better, moreover this requires no authentication at all on the xbmc interface or embedding user and password inside curl command which is no so beautiful.

A python module with callable methods or a cli interface would be much much better.
Anyway i think this will be enaugh to clear and update everything (i hope this also clears erased files)
Thanks a lot!
johnuopini Wrote:Good workaround but a native solution would be much better, moreover this requires no authentication at all on the xbmc interface or embedding user and password inside curl command which is no so beautiful.

A python module with callable methods or a cli interface would be much much better.


Patches welcome - this could be wrapped in a python module if you really wanted to.
prae5 Wrote:Patches welcome - this could be wrapped in a python module if you really wanted to.

If i find some spare time to code ill create the module.
Thanks.
I do it this way:

Code:
0 * * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1
15 9 * * * /usr/bin/xbmc-send -a "CleanLibrary(video)" >> /dev/null 2>&1
Wow, thats a much better/cleaner solution, thanks!
johnuopini Wrote:Wow, thats a much better/cleaner solution, thanks!

It does exactly the same thing?
nah, it connects to the event server through a public, non-protected connection - it's worse security wise. but hey! atleast it doesn't show any passwords eh.
spiff Wrote:nah, it connects to the event server through a public, non-protected connection - it's worse security wise. but hey! atleast it doesn't show any passwords eh.

If you are issuing commands locally (and that is what i want to do) its secure (if nobody have root access to your box).

And its more beautiful than using curl.
was thinking... does XBMC have to be running when you run /usr/bin/xbmc-send -a "UpdateLibrary(video)" and /usr/bin/xbmc-send -a "CleanLibrary(video)"? 'cus obvously it has to run to exec the curl command
prae5 Wrote:It does exactly the same thing?

AFAIK yes, because the same built in function is called (UpdateLibrary(database,[path])).

spiff Wrote:nah, it connects to the event server through a public, non-protected connection - it's worse security wise. but hey! atleast it doesn't show any passwords eh.

That's true, but I don't think it's a problem as long as the cron job runs on the same machine as XBMC. Furthermore there's a setting in XBMC to only allow events from localhost.