Articles

Print

Set XBMC to Auto Update Library

Written by Joshua Lyon on .

After getting XBMC Live installed on my Revo and getting my library setup, I couldn't find a simple option to have XBMC watch my video folder and automatically update my library. In place of this missing functionality, I figured I would setup a simple timed job to automatically update my library for me every hour.

Before I get started, I should note that there is an option to automatically update the library when the box is booted up which may work for some people. You can find this under System > Video > Update Library on Startup. This option wouldn't work for me though as I leave my box on 24/7 or at most just put it in a standby state.

See below for the details on how to setup a timed job (cron) to update your video or music library. This consists of installing the xbmc-send application and setting up a cron job (and enabling the EventServer).

Access the shell of your XBMC installation (either via SSH/putty or directly from the keyboard/Ctrl+Alt+F2) then run the following commands:

Update the Aptitude local repository:

sudo apt-get update

Enter the password for the super user if prompted (the default is 'xbmc').

Install the xbmc-send client:

sudo aptitude install xbmc-eventclients-xbmc-send

Enter the password for the super user if prompted (the default is 'xbmc').

Press Y to continue when prompted.

(Optional) Test out a command:

xbmc-send -a "Notification(Testing,XBMC Command Success.)"

You should see a quick notification box popup on your XBMC installation as soon as you press enter on the above command.

(Optional) Test if Cron is installed:

Oddly enough, cron was not installed by default on my XBMC-Live 9.11 (repack) installation so I had to manually install it first. To test if you have cron installed, try running the following command:

crontab -l

If you get an error that says something like "crontab: command not found" then you need to first install cron using the optional step below. If you get a listing of your cron entries or a message that says "no crontab for [username]" then you can skip the optional next step of installing cron.

(Optional) Install Cron:

sudo aptitude install cron

If prompted, enter the root user password and hit Y if prompted to continue.

Setup the Timed Job (Cron):

Edit the crontab entry for the root user, using the nano editor:

sudo env EDITOR=nano crontab -e

You should now see a blank, command prompt version of something similar to Wordpad. If your crontab was empty, all you will see is "# m h  dom mon dow   command". Press down to start a new line and copy the following in:

0 * * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1

Press Ctrl+O to save. Press [enter] to confirm saving to the default filename. Press Ctrl+X to exit the nano editor. Congratulations, your cronjob should now be setup to run every hour!

Other Thoughts:

Here are some other ways to setup your cron job to run. Use these in place of the default line that you pasted into the editor in the last step above:

At midnight every day:

* 0 * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1

Every 3 hours:

* */3 * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1

At 4:30pm (16:30):

30 16 * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1

If the test command doesn't work, you may need to enable the Event Server (XBMC Wiki Article). In 9.11 Camelot, this is under System > Network > Services > Allow programs on this system to control XBMC (and by default should be on).

You can also use the list of functions from the XBMC wiki to schedule other cronjobs or create your own shell scripts for more fun automation on the XBMC platform.

Comments   

 
Joshua Lyon
0 #16 Joshua Lyon 2012-01-02 13:28
@xbmc user - I'm not sure exactly what you are trying to do, but I'll try to provide some feedback. The scraper feature is intended to be used with local or networked content - it goes out to the internet to grab metadata about your local content (fanart, actors, plot, directors, etc). Being that the Apple TV 2 has very limited internal storage and no USB ports, that would leave us with networked storage to be used with scrapers. If you are looking for more information on XBMC Scrapers, I would check out the scrapers wiki page (wiki.xbmc.org/?title=Scrapers) on XBMC.org.

I don't have personal experience with IceFilms, but I understand that it's a video addon that enables you to stream video. I would recommend you visit the XBMC Forums for help with that. There is a thread related to IceFilms on the ATV2 (forum.xbmc.org/showthread.php?t=113249) as well as a dedicated thread for the IceFilms addon (forum.xbmc.org/showthread.php?t=87703).
Quote | Report to administrator
 
 
xbmc user
0 #15 xbmc user 2012-01-02 04:05
Help!

I’ve install XBMC on my jailbroken Apple TV2 device. All went well, but I’m not able to setup the scraper for IMDB to get video information for Icefilms and TV’s addons.

The problem is I don’t know the location on the Apple TV2 device where I need to setup the location of the video, TV files library in set content to use various scraper.

I could not find the files location using SSH or using the search in XBMC. I read some where online I needed to setup the file directory before installing any of the addons, but that solution is only if I was using a PC with XBMC.

I’ve swiped out the Apple TV 2 device by reinstalling Seas0npass again to start over. I’ve installed XBMC again by using the install software in NitoTV which I’ve installed again on the Apple TV2 device.

Can anyone help me setup the video directory correctly so the scrapers can find the video library to show in selecting movies in Icefilms?

Thank you.
Quote | Report to administrator
 
 
jlr2000
0 #14 jlr2000 2011-06-24 05:54
Awesome, thanks for the direction!! I'm not exactly sure how it would be written but you given me enough to do so trial and error! Doesn't look too difficult at all, once I figure out the syntax for doing my video library export (I don't use XBMC right now for music).

Thanks for the quick reply and the help!
Quote | Report to administrator
 
 
Joshua Lyon
0 #13 Joshua Lyon 2011-06-24 05:17
Yes, it can be automated. Per the XBMC Wiki (wiki.xbmc.org/?title=List_of_Built_In_Functions) you can use the following function:

Code: exportlibrary(music|video,false,filepath)<br />--->The given library will be exported to a single file stored at filepath location. above with the function below.

Code: exportlibrary(music|video,true,thumbs,overwrite,actorthumbs) <br />--->The given library is exported to single files with the given options. Here thumbs,overwrite and actorthumbs are boolean values (true or false).

If that's what you want to do, I would put together a simple shell script that runs the export, then copies the export from your HTPC to the network drive. Just replace the UpdateLibrary() part of the code from the article above. Then you can just add a cron entry to call the shell script.
Quote | Report to administrator
 
 
jlr2000
0 #12 jlr2000 2011-06-24 05:06
Thanks for this tip, was wondering if there is a way to auto export the library on a regular basis. My thought is to have XBMC auto export the library every night (like around 3am) and then copy that file out to a network drive. I've had to rebuild my XMBC box a couple times, just recently after a storm where it would not boot. If I had a recent copy of the database it would save time for the reload, right? Thoughts?

Thanks Again.
Quote | Report to administrator
 
 
Joshua Lyon
0 #11 Joshua Lyon 2010-11-24 10:44
Mark-
It shouldn't matter how the library is organized, as long as XBMC is currently recognizing your naming convention. The commands above simply tell XBMC to kick off it's internal job that updates the video library... so as long as manual library updates on your system work, then this should work as well.
Quote | Report to administrator
 
 
Mark Lines
0 #10 Mark Lines 2010-11-18 23:36
This looks like something I will have to give a go. The only question I have is your video library organization. Do you have your Movies all in one folder or are they broken down where each movie has their own folder?
Quote | Report to administrator
 
 
revellion
0 #9 revellion 2010-11-01 03:55
@Sjaak, that >> /dev/sda1 should be /dev/null... hopefully its not run as root with sda1 in it... cause if so it would write the output right onto the drive :S, not so good.
Quote | Report to administrator
 
 
Sjaak
0 #8 Sjaak 2010-09-30 02:58
First of all thanks for these handy lines.

But with the edit of the cron file, my xbmc reset it self to its default skin and settings.
I had to change the line 0 * * * * /usr/bin/xbmc-s end -a "UpdateLibrary( video)" >> /dev/null 2>&1

to

0 * * * * /usr/bin/xbmc-s end -a "UpdateLibrary( video)" >> /dev/sda1 2>&1 in order to function like normal.

I have XBMC on a USB stick, so mby that has something to do with it.
Anyway it works now :-)
Quote | Report to administrator
 
 
Joshua Lyon
0 #7 Joshua Lyon 2010-08-24 07:21
Thanks for the comments, Ramiro. The inotify method sounds pretty cool.

Per the List of Functions page (wiki.xbmc.org/?title=List_of_Built_In_Functions) from the XBMC Wiki, you would just change 'video' to 'music' in the UpdateLibrary() commands from my instructions above. eg: UpdateLibrary(m usic)
Quote | Report to administrator