Auto Rescan Library at Regular Interval?

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
MDPauley Offline
Senior Member
Posts: 263
Joined: Mar 2004
Reputation: 0
Location: Centreville, Va
Post: #16
Change the 06 (6 AM) and 18 (6 PM) to the times you want to clean you library. I would do this in both autoexec.py and CleanVideoLibrary.py.

Code:
import time
import datetime
from datetime import date
import xbmc, xbmcgui

dt = datetime.datetime.now()

timeNow = time.time()
timeAM  = time.mktime( (dt.year, dt.month, dt.day, 06, 00, 00, dt.weekday(), 0, -1) )
timePM  = time.mktime( (dt.year, dt.month, dt.day, 18, 00, 00, dt.weekday(), 0, -1) )

if (timeNow < timeAM ):
    print "Set AM time"
    minutesToUpdate = round(abs(timeAM - timeNow))

if (timeNow > timeAM ):
    print "Set PM time"
    minutesToUpdate = round(abs(timePM - timeNow))

    
xbmc.executebuiltin('XBMC.AlarmClock( CleanVideoLibrary, XBMC.RunScript(special://home/scripts/CleanVideoLibrary.py), ' + str(minutesToUpdate) + ',true)')
(This post was last modified: 2010-01-12 21:03 by MDPauley.)
find quote
tstack77 Offline
Member
Posts: 78
Joined: Oct 2008
Reputation: 0
Location: Chicago
Post: #17
Awesome. That is a lot more complicated than I expected, and I had zero chance of making that on my own.

Thank you
find quote
marcus2004 Offline
Junior Member
Posts: 1
Joined: Dec 2009
Reputation: 0
Post: #18
joshua.lyon Wrote: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.

Joshua I have used the info on your blog to do this before, but for whatever reason I don't think that the script is exiting properly after or something as after a day or two my machine slows down. As soon as I remove the cron items for the update it is fine. I had it set to 30 min updates and once a day cleaning.
I am trying try this python scripts to see if it is better.
find quote
jfgi Offline
Junior Member
Posts: 24
Joined: Jan 2010
Reputation: 0
Post: #19
tstack77 Wrote: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

Clean just makes XBMC (Windows, v9.11 and r28256) freeze for me. There's no issue when i run it from the menu, but everytime i run it from a script, it freezes.
find quote
tetodbs Offline
Junior Member
Posts: 47
Joined: Jan 2010
Reputation: 0
Post: #20
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...

How to make it work for latest svn with addon system?

Thanks
find quote
tstack77 Offline
Member
Posts: 78
Joined: Oct 2008
Reputation: 0
Location: Chicago
Post: #21
Just updated to RC1, this doesn't seem to function any longer. I also set this as a favorite before to be run when needed on demand, but I can't access appdata anymore from the file manager.

Is there a workaround for this very needed function that I'm missing?
find quote
tboooe Offline
Fan
Posts: 456
Joined: Dec 2010
Reputation: 0
Post: #22
Hate to dig up such an old thread but was wondering if the using the builtin library update function still works in Dharma release?
find quote
torchedlh Offline
Junior Member
Posts: 14
Joined: Feb 2011
Reputation: 0
Post: #23
Maybe I'm missing something here but there's a plugin that you can add within XBMC that will auto update your library on specified intervals...
find quote
tboooe Offline
Fan
Posts: 456
Joined: Dec 2010
Reputation: 0
Post: #24
torchedlh Wrote:Maybe I'm missing something here but there's a plugin that you can add within XBMC that will auto update your library on specified intervals...

There is but I cant get it to work right. My library never updated automatically so I was hoping I could use the builtin functions and write my own script.
find quote
prophetizer Offline
Senior Member
Posts: 283
Joined: Sep 2008
Reputation: 2
Post: #25
tboooe Wrote:There is but I cant get it to work right. My library never updated automatically so I was hoping I could use the builtin functions and write my own script.

the library updater works no problem for me, but what doesn't work is the clean library function, i simply don't think it works in Dharma except by manually selecting it from the video settings, i've put it in advancedsettings.xml and nothing, tried via HTTP also nothing.

--
[Image: watched-clearlogo.jpg]
find quote
tboooe Offline
Fan
Posts: 456
Joined: Dec 2010
Reputation: 0
Post: #26
prophetizer Wrote:the library updater works no problem for me, but what doesn't work is the clean library function, i simply don't think it works in Dharma except by manually selecting it from the video settings, i've put it in advancedsettings.xml and nothing, tried via HTTP also nothing.

Are you saying the addon works or the builtin functions via custom script?
find quote
prophetizer Offline
Senior Member
Posts: 283
Joined: Sep 2008
Reputation: 2
Post: #27
both for updating, and someone just pointed out an issue with my advancedsettings.xml file that should fix my clean up issue.

--
[Image: watched-clearlogo.jpg]
find quote
tboooe Offline
Fan
Posts: 456
Joined: Dec 2010
Reputation: 0
Post: #28
OK great. I will try the custom script. Would you mind letting me know how you are doing the automatic cleanup script in advanced settings?
find quote
prophetizer Offline
Senior Member
Posts: 283
Joined: Sep 2008
Reputation: 2
Post: #29
Code:
<advancedsettings>
  <videolibrary>
    <cleanonupdate>true</cleanonupdate>
  </videolibrary>
</advancedsettings>

--
[Image: watched-clearlogo.jpg]
find quote
castortray Offline
Fan
Posts: 501
Joined: May 2009
Reputation: 0
Post: #30
I'm using this plugin, and works perfectly for me,

http://www.mediafire.com/?pyqmqxqqfbq3paq

just unpack to C:\Users\%username%\AppData\Roaming\XBMC\addons

or try install addon from zip
find quote