Kodi Community Forum
Auto Rescan Library at Regular Interval? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Auto Rescan Library at Regular Interval? (/showthread.php?tid=64893)

Pages: 1 2 3


Auto Rescan Library at Regular Interval? - altern8 - 2009-12-24

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


- outleradam - 2009-12-24

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.


- altern8 - 2009-12-24

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


- sho - 2009-12-24

rwparris2 created a python script to do just that.
Hunt around in this forum to find it.


- olrik - 2009-12-24

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


- paddycarey - 2009-12-24

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


- outleradam - 2009-12-28

I added a feature to mythicalLibrarian to update the library, clean out the old junk that was deleted and send a UI notification


- bossanova808 - 2009-12-28

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.


- altern8 - 2009-12-28

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>



- dc2447 - 2009-12-28

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?


- joshua.lyon - 2010-01-05

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.


- MDPauley - 2010-01-05

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...


- altern8 - 2010-01-05

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


- MDPauley - 2010-01-05

Windows: %appdata%\xbmc\scripts\
Linux: ~/.xbmc/scripts/
OSX: not sure...


- tstack77 - 2010-01-12

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