Kodi Community Forum

Full Version: Auto Rescan Library at Regular Interval?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
hi everyone, im looking to see how i can setup xbmc to rescan my library to cleanup/add new titles as my collection shrinks and expands on a daily/weekly basis ... i found these commands but have no idea where to begin to use them in a XBMC Live environment ... has anyone work on this before? i did a google but only found references to it on the plex forum ...

http://wiki.xbmc.org/?title=List_of_Built_In_Functions
I'd like to see the same feature. Where XBMC will monitor it's library folders and compensate for changes in the files every so often, both adds and deletes.
for now, I created a keymap.XML and assign the rescan function to one of my mce remote buttons ... it's not exactly what i'm hoping to achieve but this is a work around I think I can live with
rwparris2 created a python script to do just that.
Hunt around in this forum to find it.
1/ enable EventServer

2/ Install the xbmc-eventclients-xbmc-send package

3/ Schedule the Library Update with 'crontab -e'

Code:
xbmc@XBMCLive:~$ crontab -l
# m h  dom mon dow   command
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
xbmc@XBMCLive:~$ aptitude search xbmc-send
i   xbmc-eventclients-xbmc-send     - XBMC Media Center (Event Client XBMC-SEND
Update every hours, Cleaning everyday at 9:15
or you could turn on the event server, install xbmc-eventclients-xbmc-send from the ppa and add the following line to your crontab with "crontab -e":

0 * * * * xbmc-send --action="XBMC.updatelibrary(video)"

your library will then update on the hour every hour

i use this along with cleanonupdate in advancedsettings.xml and it works a treat
I added a feature to mythicalLibrarian to update the library, clean out the old junk that was deleted and send a UI notification
altern8 Wrote:for now, I created a keymap.XML and assign the rescan function to one of my mce remote buttons ... it's not exactly what i'm hoping to achieve but this is a work around I think I can live with

Can you post this? I'd prefer an on-demand, one click option than a timed option.
this is what my keymap.xml looks like... so whenever i press the #1 button, it executes a update library command ... im going to see how i can use the suggested timed option since i would like to have but options at my disposal ... thanks everyone ...

Code:
<keymap>
<global>
   <remote>
     <one>XBMC.UpdateLibrary(video)</one>
   </remote>
</global>
</keymap>
bossanova808 Wrote:Can you post this? I'd prefer an on-demand, one click option than a timed option.

What is wrong with pressing update library on your remote?
For other people looking for details on how to have your library automatically update on a regular interval, I've posted a step-by-step how-to on my blog. Check it out and post back here (or in the comments) if you have questions.
autoexec.py
Code:
import xbmc, xbmcgui

xbmc.executebuiltin('XBMC.AlarmClock( VideoLibraryUpdater, XBMC.RunScript(special://home/scripts/VideoLibraryUpdater.py),45,true)')

VideoLibraryUpdater.py
Code:
import xbmc, xbmcgui
xbmc.executebuiltin('XBMC.UpdateLibrary(video)')
xbmc.executebuiltin('XBMC.AlarmClock( VideoLibraryUpdater, XBMC.RunScript(special://home/scripts/VideoLibraryUpdater.py),45,true)')

Put both scripts in your special://home/scripts directory. These 2 scripts will create a timed event that will update the library every 45 minutes...
MDPauley Wrote:autoexec.py
Code:
import xbmc, xbmcgui

xbmc.executebuiltin('XBMC.AlarmClock( VideoLibraryUpdater, XBMC.RunScript(special://home/scripts/VideoLibraryUpdater.py),45,true)')

VideoLibraryUpdater.py
Code:
import xbmc, xbmcgui
xbmc.executebuiltin('XBMC.UpdateLibrary(video)')
xbmc.executebuiltin('XBMC.AlarmClock( VideoLibraryUpdater, XBMC.RunScript(special://home/scripts/VideoLibraryUpdater.py),45,true)')

Put both scripts in your special://home/scripts directory. These 2 scripts will create a timed event that will update the library every 45 minutes...

thanks for the code, sorry for the noobie question but where exactly is "special://home/scripts" located? i couldnt find it logging in as root or xbmc
Windows: %appdata%\xbmc\scripts\
Linux: ~/.xbmc/scripts/
OSX: not sure...
MDPauley, your scripts worked great! I even modified one to clean the library twice a day as well (simple I know, but I am a complete noob with scripting).

I made it by creating a CleanVideoLibrary.py and adding the job to autoexec.py

CleanVideoLibrary.py
Code:
import xbmc, xbmcgui
xbmc.executebuiltin('XBMC.CleanLibrary(video)')
xbmc.executebuiltin('XBMC.AlarmClock( CleanVideoLibrary, XBMC.RunScript(special://home/scripts/CleanVideoLibrary.py),720,true)')

autoexec.py
Code:
import xbmc, xbmcgui

xbmc.executebuiltin('XBMC.AlarmClock( VideoLibraryUpdater, XBMC.RunScript(special://home/scripts/VideoLibraryUpdater.py),45,true)')
xbmc.executebuiltin('XBMC.AlarmClock( CleanVideoLibrary, XBMC.RunScript(special://home/scripts/CleanVideoLibrary.py),720,true)')

I do have one quick question though that 20 minutes on google couldn't help me with. How do I set an exact time of day to run the script instead of every 12 hours? I tried changing the minutes to xx:yy format (18:15), but that wasn't the answer.

Thanks for all the help Smile
Pages: 1 2 3