The branch, eden has been updated
via 0928856b417585692fb069483b7e842d79927ac7 (commit)
via daec02cb0d85578646852320fca22491408cab6d (commit)
from d30979499c4b002814906d98adc6c53284da9ada (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=0928856b417585692fb069483b7e842d79927ac7
commit 0928856b417585692fb069483b7e842d79927ac7
Author: amet <[email protected]>
Date: Sun Apr 1 17:40:35 2012 +0400
[service.libraryautoupdate] -0.6.0
-updated the manual run interface to include information about when the
updater will run again
[B]Version 0.5.7[/B]
- merged 'standard' and 'advanced' usage to follow more of the same
codebase. Now the standard timer uses a cron expression as well and will start
at the top of every hour
[B]Version 0.5.8[/B]
- added a 1 minute delay timer before running a scan if XBMC has just
exited playback. This should help in scenerios where ending media viewing
results in an immediate scan that the user didn't want.
[B]Version 0.5.9[/B]
- added a custom video path option to only scan a specific video path
instead of the entire library
[B]Version 0.6.0[/B]
- added "Cleaning" category to schedule a clean operation of the
music/video databases. This operation can happen immediately after a scan or
once per day/week/month. Verifying source paths before a clean is also supported
diff --git a/service.libraryautoupdate/README.txt
b/service.libraryautoupdate/README.txt
index 000f4d5..de5577d 100644
--- a/service.libraryautoupdate/README.txt
+++ b/service.libraryautoupdate/README.txt
@@ -4,14 +4,17 @@ Thanks to pkscuot for several small tweaks to this addon!
General Settings:
-Update video - updates video library
-update music - updates music library
Show Notifications - shows notifications when the updater will run again
Run During Playback - should the addon run when you are playing media
+Update video - updates video library
+update music - updates music library
+Video path - updates a specific video path. DISCLAIMER - the path you select
must already be in the video database and have content selected. The path must
also match your source path exactly.
+
+Timer Options:
-Timers:
+Startup Delay - if an update should run on startup (dependant on the time the
last update has ran) this will delay it from running for a few minutes to allow
other XBMC process to function.
-Standard Timer - specify an interval to run the library update process. It
will be launched every X hours within the interval unless on of the conditions
specified by you as been met (don't run during media playback, etc) in which
case it will be run at the next earliest convenience. There is also a startup
delay that can be used on XBMC startup
+Standard Timer - specify an interval to run the library update process. It
will be launched every X hours within the interval unless on of the conditions
specified by you as been met (don't run during media playback, etc) in which
case it will be run at the next earliest convenience.
Advanced Timer - specify a cron expression to use as an interval for the
update process. By default the expression will run at the top of every hour.
More advanced expressions can be configured such as:
@@ -27,4 +30,12 @@ Example:
0,15,30,45 0,15-18 * * * - runs update every quarter hour during
midnight hour and 3pm-6pm
-Read up on cron (http://en.wikipedia.org/wiki/Cron) for more information on
how to create these expressions
\ No newline at end of file
+Read up on cron (http://en.wikipedia.org/wiki/Cron) for more information on
how to create these expressions
+
+Cleaning the Library:
+
+Cleaning the Music/Video Libraries is not enabled by default. If you choose to
do this you can select from a few options. Keep in mind that the cleaning
operations will only run if the Auto Update addon is also enabled to update
those specific libraries.
+
+Verify Sources Before Clean - this will verify all of your media paths (music
or video) before running a clean operation. If any of these paths are
inaccessible the clean operation will not continue and an error will be logged
+
+Frequency - There are several frequency options. "After Update" will run a
clean immediately following a standard update. The Day/Week/Month options will
schedule a clean task to happen. Cleaning the Video Library is hardcoded for
midnight and the music library at 2am. Weekly updates occur on Sunday and
Monthly updates occur on the first of each month - these values are hardcoded.
\ No newline at end of file
diff --git a/service.libraryautoupdate/addon.xml
b/service.libraryautoupdate/addon.xml
index a598b63..c794926 100644
--- a/service.libraryautoupdate/addon.xml
+++ b/service.libraryautoupdate/addon.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.libraryautoupdate"
- name="XBMC Library Auto Update" version="0.5.6" provider-name="robweber">
+ name="XBMC Library Auto Update" version="0.6.0" provider-name="robweber">
<requires>
<import addon="xbmc.python" version="2.0"/>
</requires>
@@ -10,8 +10,8 @@
<extension point="xbmc.service" library="default.py" start="login">
</extension>
<extension point="xbmc.addon.metadata">
- <summary lang="en">Update your XBMC Video and Music Libraries on a timer.
Recently rewritten to run as an XBMC Service.</summary>
- <description lang="en">This is an XBMC Service that will update your music
and video libraries on a timer. You can select an interval to scan specific
databases (Audio,Video,Both) or you can set a cron-style timer. If you are
playing an audio or video file when the timer starts it can skip the library
update process until it is completed so that you're media experience is not
interrupted. </description>
+ <summary lang="en">Update your XBMC Video and Music Libraries on a timer.
Timer runs as an XBMC service so you never miss an update.</summary>
+ <description lang="en">This is an XBMC Service that will update your music
and video libraries on a timer. You can select a different interval to scan
your media databases (Audio,Video,Both) or you can set a cron-style timer for
greater control. If you are playing an audio or video file when the timer
starts it can skip the library update process until it is completed so that
you're media experience is not interrupted. Updating a specific Video Path, and
Cleaning the Music/Video libraries is now supported.</description>
<platform>all</platform>
</extension>
</addon>
diff --git a/service.libraryautoupdate/changelog.txt
b/service.libraryautoupdate/changelog.txt
index 2d9a1da..53cffdb 100644
--- a/service.libraryautoupdate/changelog.txt
+++ b/service.libraryautoupdate/changelog.txt
@@ -54,4 +54,20 @@
[B]Version 0.5.6[/B]
--updated the manual run interface to include information about when the
updater will run again
\ No newline at end of file
+-updated the manual run interface to include information about when the
updater will run again
+
+[B]Version 0.5.7[/B]
+
+- merged 'standard' and 'advanced' usage to follow more of the same codebase.
Now the standard timer uses a cron expression as well and will start at the top
of every hour
+
+[B]Version 0.5.8[/B]
+
+- added a 1 minute delay timer before running a scan if XBMC has just exited
playback. This should help in scenerios where ending media viewing results in
an immediate scan that the user didn't want.
+
+[B]Version 0.5.9[/B]
+
+- added a custom video path option to only scan a specific video path instead
of the entire library
+
+[B]Version 0.6.0[/B]
+
+- added "Cleaning" category to schedule a clean operation of the music/video
databases. This operation can happen immediately after a scan or once per
day/week/month. Verifying source paths before a clean is also supported
\ No newline at end of file
diff --git a/service.libraryautoupdate/manual.py
b/service.libraryautoupdate/manual.py
index a777fbc..050f1ae 100644
--- a/service.libraryautoupdate/manual.py
+++ b/service.libraryautoupdate/manual.py
@@ -7,11 +7,18 @@ Addon = xbmcaddon.Addon(addon_id)
autoUpdate = AutoUpdater()
-nextRun = autoUpdate.calcNextRun()
+nextRun = autoUpdate.showNotify(False)
#check if we should run updates
runUpdate =
xbmcgui.Dialog().yesno(Addon.getLocalizedString(30010),Addon.getLocalizedString(30011)
+ nextRun,Addon.getLocalizedString(30012))
if(runUpdate):
#run the program
- xbmc.log("Update Library Manual Run...")
- autoUpdate.runUpdates()
+ autoUpdate.log("Update Library Manual Run...")
+
+ #trick the auto updater into resetting the last_run time
+ autoUpdate.last_run = 0
+ autoUpdate.writeLastRun()
+
+ #update the schedules and evaluate them
+ autoUpdate.createSchedules(True)
+ autoUpdate.evalSchedules()
diff --git a/service.libraryautoupdate/resources/language/English/strings.xml
b/service.libraryautoupdate/resources/language/English/strings.xml
index afb8a5f..7b45fd0 100644
--- a/service.libraryautoupdate/resources/language/English/strings.xml
+++ b/service.libraryautoupdate/resources/language/English/strings.xml
@@ -6,14 +6,28 @@
<string id="30002">Update Video Library</string>
<string id="30003">Update Music Library</string>
<string id="30004">Startup Delay (minutes)</string>
- <string id="30008">Run during playback</string>
- <string id="30009">Show Notifications</string>
-
- <string id="30005">Timers</string>
+ <string id="30005">Video</string>
<string id="30006">Used Advanced Timer</string>
<string id="30007">Cron Expression</string>
+ <string id="30008">Run during playback</string>
+ <string id="30009">Show Notifications</string>
<!-- gui -->
<string id="30011">Update will run again </string>
<string id="30012">Do you wish to manually run an update?</string>
+
+ <string id="30013">Music</string>
+ <string id="30014">Cleaning</string>
+ <string id="30015">Update Specific Path</string>
+ <string id="30016">Video Path</string>
+ <string id="30017">Read Disclaimer</string>
+
+ <!-- disclaimer -->
+ <string id="30018">Video Paths Disclaimer</string>
+ <string id="30019">Path must already be a video source with
content</string>
+ <string id="30020">Path must match source path exactly to scan</string>
+
+ <string id="30021">Clean Libraries</string>
+ <string id="30022">Verify Sources Before Clean</string>
+ <string id="30023">Frequency</string>
</strings>
diff --git a/service.libraryautoupdate/resources/settings.xml
b/service.libraryautoupdate/resources/settings.xml
index 86fe273..779fa14 100644
--- a/service.libraryautoupdate/resources/settings.xml
+++ b/service.libraryautoupdate/resources/settings.xml
@@ -1,15 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<settings>
<category id="general" label="30000">
- <setting id="update_video" type="bool" label="30002" default="true"
/>
- <setting id="update_music" type="bool" label="30003"
default="false" />
+ <setting id="startup_delay" type="enum" values="0|1|2|3|4|5"
label="30004" default="0" />
<setting id="notify_next_run" type="bool" label="30009"
default="true" />
<setting id="run_during_playback" type="bool" label="30008"
default="false" />
</category>
- <category id="advanced" label="30005">
- <setting id="use_advanced_timer" type="bool" label="30006"
default="false"/>
- <setting id="timer_amount" type="enum" values="1|2|5|10|15|24"
label="30001" default="2" enable="!eq(-1,true)" />
- <setting id="startup_delay" type="enum" values="0|1|2|3|4|5"
label="30004" default="0" enable="!eq(-2,true)" />
- <setting id="cron_expression" type="text" label="30007"
enable="eq(-3,true)" default="0 * * * *" />
+ <category id="video_timer" label="30005">
+ <setting id="update_video" type="bool" label="30002"
default="true" />
+ <setting id="video_advanced_timer" type="bool" label="30006"
default="false" enable="eq(-1,true)"/>
+ <setting id="video_timer" type="enum" values="1|2|4|6|12|24"
label="30001" default="2" enable="!eq(-1,true) + eq(-2,true)"
visible="!eq(-1,true)" />
+ <setting id="video_cron_expression" type="text" label="30007"
visible="eq(-2,true)" enable="eq(-2,true) + eq(-3,true)" default="0 * * * *" />
+ <setting type="sep" />
+ <setting id="use_custom_1_path" type="bool" label="30015"
default="false" />
+ <setting id="help_button" type="action"
action="RunScript(special://home/addons/service.libraryautoupdate/disclaimer.py)"
label="30017" visible="eq(-1,true)"/>
+ <setting id="custom_1_advanced_timer" type="bool" label="30006"
default="false" enable="eq(-2,true)" visible="eq(-2,true)" />
+ <setting id="custom_1_timer" type="enum" values="1|2|4|6|12|24"
label="30001" default="2" enable="!eq(-1,true) + eq(-3,true)"
visible="!eq(-1,true) + eq(-3,true)" />
+ <setting id="custom_1_cron_expression" type="text"
label="30007" enable="eq(-2,true) + eq(-4,true)" default="0 * * * *"
visible="eq(-2,true) + eq(-4,true)" />
+ <setting id="custom_1_scan_path" type="folder" label="30016"
enable="eq(-5,true)" visible="eq(-5,true)" />
+ </category>
+ <category id="music_timer" label="30013">
+ <setting id="update_music" type="bool" label="30003"
default="false" />
+ <setting id="music_advanced_timer" type="bool" label="30006"
default="false" enable="eq(-1,true)" />
+ <setting id="music_timer" type="enum" values="1|2|4|6|12|24"
label="30001" default="2" enable="!eq(-1,true) + eq(-2,true)"
visible="!eq(-1,true)" />
+ <setting id="music_cron_expression" type="text" label="30007"
enable="eq(-2,true) + eq(-3,true)" default="0 * * * *" visible="eq(-2,true)" />
+ </category>
+ <category id="clean_timer" label="30014">
+ <setting id="clean_libraries" type="bool" label="30021"
default="false" />
+ <setting id="verify_paths" type="bool" label="30022"
default="false" enable="eq(-1,true)"/>
+ <setting id="clean_timer" type="enum" values="After Update|Once
Per Day|Once Per Week|Once Per Month" label="30023" default="0"
enable="eq(-2,true)" />
</category>
</settings>
diff --git a/service.libraryautoupdate/service.py
b/service.libraryautoupdate/service.py
index d640c4a..9aefeeb 100644
--- a/service.libraryautoupdate/service.py
+++ b/service.libraryautoupdate/service.py
@@ -2,171 +2,244 @@ import time
from datetime import datetime
import xbmc
import xbmcaddon
+import xbmcvfs
import os
from resources.lib.croniter import croniter
+class CronSchedule:
+ expression = ''
+ name = 'library'
+ timer_type = 'xbmc'
+ command = 'UpdateLibrary(video)'
+ next_run = 0
+ on_delay = False #used to defer processing until after player finishes
+ clean_library = False #if clean library command should be run after this
schedule
+
+ def cleanLibrarySchedule(self,selectedIndex):
+ if(selectedIndex == 1):
+ #once per day
+ return "* * *"
+ elif (selectedIndex == 2):
+ #once per week
+ return "* * 0"
+ else:
+ #once per month
+ return "1 * *"
+
class AutoUpdater:
addon_id = "service.libraryautoupdate"
Addon = xbmcaddon.Addon(addon_id)
datadir = Addon.getAddonInfo('profile')
addondir = Addon.getAddonInfo('path')
+ last_run = 0
sleep_time = 10
- forceUpdate = False
- previousTimer = 0
+ schedules = []
+ settings_update_time = 0
#setup the timer amounts
timer_amounts = {}
timer_amounts['0'] = 1
timer_amounts['1'] = 2
- timer_amounts['2'] = 5
- timer_amounts['3'] = 10
- timer_amounts['4'] = 15
+ timer_amounts['2'] = 4
+ timer_amounts['3'] = 6
+ timer_amounts['4'] = 12
timer_amounts['5'] = 24
def __init__(self):
self.readLastRun()
+
+ #force and update on startup to create the array
+ self.createSchedules(True)
def runProgram(self):
-
- if(self.Addon.getSetting('use_advanced_timer') == 'false'):
- #check if we should delay the first run
- if(int(self.Addon.getSetting("startup_delay")) != 0):
+ #a one-time catch for the startup delay
+ if(int(self.Addon.getSetting("startup_delay")) != 0):
+ count = 0
+ while count < len(self.schedules):
+ if(time.time() > self.schedules[count].next_run):
+ #we missed at least one update, fix this
+ self.schedules[count].next_run = time.time() +
int(self.Addon.getSetting("startup_delay")) * 60
+ count = count + 1
- #check if we would have run an update anyway
- if(time.time() >= self.last_run +
(self.timer_amounts[self.Addon.getSetting('timer_amount')] * 60 * 60)):
- #trick system by subtracting the timer amount then adding
a delay (now - timer + delay = nextrun)
- self.last_run = time.time() -
(self.timer_amounts[self.Addon.getSetting('timer_amount')] * 60 *60) +
(int(self.Addon.getSetting("startup_delay")) * 60)
- self.writeLastRun()
- self.log("Setting delay at " +
self.Addon.getSetting("startup_delay") + " minute")
-
- self.showNotify(self.last_run +
(self.timer_amounts[self.Addon.getSetting('timer_amount')] * 60 * 60))
- self.currentTimer = self.Addon.getSetting('timer_amount')
- else:
- self.currentTimer = self.Addon.getSetting("cron_expression")
- cronExp =
croniter(self.Addon.getSetting("cron_expression"),datetime.now())
- self.showNotify(cronExp.get_next(float))
-
- #run until XBMC quits
+ #program has started, check if we should show a notification
+ self.showNotify()
+
while(not xbmc.abortRequested):
- self.checkTimer()
-
- if(self.Addon.getSetting('use_advanced_timer') == 'true'):
- self.runAdvanced()
- else:
- self.runStandard()
-
- #put the thread to sleep for x number of seconds
+ self.readLastRun()
+
+ self.evalSchedules()
+
time.sleep(self.sleep_time)
-
- def runStandard(self):
+ def evalSchedules(self):
now = time.time()
-
- self.readLastRun()
+ self.createSchedules()
+
+ count = 0
+ tempLastRun = self.last_run
+ while count < len(self.schedules):
+ cronJob = self.schedules[count]
- #check if we should run an update
- if(now >= self.last_run + (self.timer_amounts[self.currentTimer] * 60
* 60)):
- #make sure player isn't running
- if(xbmc.Player().isPlaying() == False or
self.Addon.getSetting('run_during_playback') == 'true'):
- if(self.scanRunning() == False):
- self.runUpdates()
- self.showNotify(self.last_run +
(self.timer_amounts[self.currentTimer] * 60 * 60))
- self.log("will run again in " +
str(self.timer_amounts[self.currentTimer]) + " hours")
+ if(cronJob.next_run <= now and now > tempLastRun + 60):
+ if(xbmc.Player().isPlaying() == False or
self.Addon.getSetting("run_during_playback") == "true"):
+ #check if this scan was delayed due to playback
+ if(cronJob.on_delay == True):
+ #add another minute to the delay
+ self.schedules[count].next_run = now + 60
+ self.schedules[count].on_delay = False
+ self.log(cronJob.name + " paused due to playback")
- else:
- self.log("Player is running, waiting until finished")
-
-
+ elif(self.scanRunning() == False):
+ #run the command for this job
+ self.log(cronJob.name)
- def runAdvanced(self):
- self.readLastRun()
- now = time.time()
-
- #create the cron expression
- cron = croniter(self.currentTimer,datetime.fromtimestamp(now - 60))
- runCron = cron.get_next(float)
-
- #check if we should run, and that we haven't already run the update
within the past minute - alternatively check that we shouldn't force an update
- if((runCron <= now and time.time() > self.last_run + 60) or
self.forceUpdate):
- #make sure player isn't running
- if(xbmc.Player().isPlaying() == False or
self.Addon.getSetting('run_during_playback') == 'true'):
- self.forceUpdate = False
- if(self.scanRunning() == False):
- self.runUpdates()
- nextRun = cron.get_next(float)
- self.showNotify(nextRun)
- self.log("will run again in " + self.nextRun(nextRun))
-
- else:
- #force an update if this
- self.forceUpdate = True
- self.log("Player is running, waiting until finished")
-
- def scanRunning(self):
- #check if any type of scan is currently running
- if(xbmc.getCondVisibility('Library.IsScanningVideo') or
xbmc.getCondVisibility('Library.IsScanningMusic')):
- return True
- else:
- return False
-
- def runUpdates(self):
- #run the update
- if(self.Addon.getSetting('update_video') == 'true'):
- self.log('Updating Video')
- xbmc.executebuiltin('UpdateLibrary(video)')
- time.sleep(1)
-
- if(self.Addon.getSetting('update_music') == 'true'):
- #check if scan is running again, wait until finished if it is
- while(self.scanRunning()):
- time.sleep(10)
-
- self.log('Update Music')
- xbmc.executebuiltin('UpdateLibrary(music)')
-
- #reset the last run timer - mod to top of minute (thanks pkscuot)
- self.last_run = time.time() - (time.time() % 60)
- self.writeLastRun()
+ if(cronJob.timer_type == 'xbmc'):
+ xbmc.executebuiltin(cronJob.command)
+ self.waitForScan()
+ else:
+ self.cleanLibrary(cronJob)
- def readLastRun(self):
+ self.last_run = time.time() - (time.time() % 60)
+ self.writeLastRun()
+
+ #find the next run time
+ cronJob.next_run =
self.calcNextRun(cronJob.expression,now)
+ self.schedules[count] = cronJob
+
+ #show any notifications
+ self.showNotify()
+
+ #check if we should clean the library too
+ if(cronJob.clean_library):
+ self.cleanLibrary(cronJob)
+ else:
+ self.schedules[count].on_delay = True
+ self.log("Player is running, wait until finished")
+
+ count = count + 1
+ def createSchedules(self,forceUpdate = False):
+ mod_time = self.settings_update_time
+
try:
- f = open(xbmc.translatePath(self.datadir + "last_run.txt"),"r")
- self.last_run = float(f.read())
- f.close()
- except IOError:
- #the file doesn't exist, most likely first time running
- self.last_run = 0
-
+ #get the last modified time of the file
+ mod_time = os.path.getmtime(xbmc.translatePath(self.datadir) +
"settings.xml")
+ except:
+ #don't do anything here
+ mod_time = self.settings_update_time
- def writeLastRun(self):
- #create the addon folder if it doesn't exist
- if(not os.path.exists(xbmc.translatePath(self.datadir))):
- os.makedirs(xbmc.translatePath(self.datadir))
-
- f = open(xbmc.translatePath(self.datadir + "last_run.txt"),"w")
-
- #write out the value for the last time the program ran
- f.write(str(self.last_run));
- f.close();
+ if(mod_time > self.settings_update_time or forceUpdate):
+ self.log("update timers")
+ self.schedules = []
- def showNotify(self,timestamp):
- #don't show anything if the update will happen now
- if(timestamp > time.time() and
self.Addon.getSetting('notify_next_run') == 'true'):
- self.log(self.addondir)
- xbmc.executebuiltin("Notification(Library Auto Update,Next run: "
+ self.nextRun(timestamp) + ",4000," + xbmc.translatePath(self.addondir +
"/icon.png") + ")")
+ clean_after_update = False
+ if(self.Addon.getSetting('clean_libraries') == 'true'):
+ #create clean schedule (if needed)
+ if(int(self.Addon.getSetting("clean_timer")) == 0):
+ clean_after_update = True #clean after executing updates
+ else:
+ #create a separate schedule for cleaning - use right now
rather than last_run, never 'catch-up'
+ clean_after_update = False
- def calcNextRun(self):
- if(self.Addon.getSetting('use_advanced_timer') == 'false'):
- return self.nextRun(self.last_run +
(self.timer_amounts[self.Addon.getSetting('timer_amount')] * 60 * 60))
- else:
- cronExp =
croniter(self.Addon.getSetting("cron_expression"),datetime.now())
- return self.nextRun(cronExp.get_next(float))
+ if(self.Addon.getSetting('update_video') == 'true' or
self.Addon.getSetting('use_custom_1_path') == 'true'):
+ #video clean schedule starts at 12am
+ aSchedule = CronSchedule()
+ aSchedule.name = 'Clean Video Library'
+ aSchedule.timer_type = self.addon_id
+ aSchedule.command = 'video'
+ aSchedule.expression = "0 0 " +
aSchedule.cleanLibrarySchedule(int(self.Addon.getSetting("clean_timer")))
+ aSchedule.next_run =
self.calcNextRun(aSchedule.expression,time.time())
+
+ self.schedules.append(aSchedule)
+
+ if(self.Addon.getSetting('update_music') == 'true'):
+ #music clean schedule starts at 2am
+ aSchedule = CronSchedule()
+ aSchedule.name = 'Clean Music Library'
+ aSchedule.timer_type = self.addon_id
+ aSchedule.command = 'music'
+ aSchedule.expression = "0 2 " +
aSchedule.cleanLibrarySchedule(int(self.Addon.getSetting("clean_timer")))
+ aSchedule.next_run =
self.calcNextRun(aSchedule.expression,time.time())
+
+ self.schedules.append(aSchedule)
+
+
+ if(self.Addon.getSetting('update_video') == 'true'):
+ #create the video schedule
+ aSchedule = CronSchedule()
+ aSchedule.name = 'Update Video Library'
+ aSchedule.command = 'UpdateLibrary(video)'
+ aSchedule.expression = self.checkTimer('video')
+ aSchedule.next_run =
self.calcNextRun(aSchedule.expression,self.last_run)
+ aSchedule.clean_library = clean_after_update
+
+ self.schedules.append(aSchedule)
+
+ if(self.Addon.getSetting('update_music') == 'true'):
+ #create the music schedule
+ aSchedule = CronSchedule()
+ aSchedule.name = 'Update Music Library'
+ aSchedule.command = 'UpdateLibrary(music)'
+ aSchedule.expression = self.checkTimer('music')
+ aSchedule.next_run =
self.calcNextRun(aSchedule.expression,self.last_run)
+ aSchedule.clean_library = clean_after_update
+
+ self.schedules.append(aSchedule)
+
+ if(self.Addon.getSetting('use_custom_1_path') == 'true'):
+ #create a custom video path schedule
+ aSchedule = CronSchedule()
+ aSchedule.name = 'Specific Video Path'
+ aSchedule.command = 'UpdateLibrary(video,' +
self.Addon.getSetting('custom_1_scan_path') + ')'
+ aSchedule.expression = self.checkTimer('custom_1')
+ aSchedule.next_run =
self.calcNextRun(aSchedule.expression,self.last_run)
+ aSchedule.clean_library = clean_after_update
+ self.schedules.append(aSchedule)
- def nextRun(self,nextRun):
+ #update the mod time for the file
+ self.settings_update_time = mod_time
+
+ #show any notifications
+ self.showNotify(not forceUpdate)
+
+ def checkTimer(self,settingName):
+ result = ''
+
+ #figure out if using standard or advanced timer
+ if(self.Addon.getSetting(settingName + '_advanced_timer') == 'true'):
+ #copy the expression
+ result = self.Addon.getSetting(settingName + "_cron_expression")
+ else:
+ result = '0 */' +
str(self.timer_amounts[self.Addon.getSetting(settingName + "_timer")]) + ' * *
*'
+
+ return result
+
+ def calcNextRun(self,cronExp,startTime):
+
+ #create croniter for this expression
+ cron = croniter(cronExp,startTime)
+ nextRun = cron.get_next(float)
+
+ return nextRun
+
+ def showNotify(self,displayToScreen = True):
+ #go through and find the next schedule to run
+ next_run_time = CronSchedule()
+ for cronJob in self.schedules:
+ if(cronJob.next_run < next_run_time.next_run or
next_run_time.next_run == 0):
+ next_run_time = cronJob
+
+ inWords = self.nextRunCountdown(next_run_time.next_run)
+ #show the notification (if applicable)
+ if(next_run_time.next_run > time.time() and
self.Addon.getSetting('notify_next_run') == 'true' and displayToScreen == True):
+ xbmc.executebuiltin("Notification(Library Auto Update," +
next_run_time.name + " " + inWords + ",4000," +
xbmc.translatePath(self.addondir + "/resources/images/clock.png") + ")")
+
+ return inWords
+
+ def nextRunCountdown(self,nextRun):
#compare now with next date
- cronDiff = nextRun - time.time() + 60
+ cronDiff = nextRun - time.time()
if cronDiff < 0:
return ""
@@ -191,17 +264,65 @@ class AutoUpdater:
return result
- def checkTimer(self):
- if(self.Addon.getSetting('use_advanced_timer') == 'false'):
- if self.Addon.getSetting('timer_amount') != self.currentTimer:
- self.showNotify(self.last_run +
(self.timer_amounts[self.Addon.getSetting('timer_amount')] * 60 * 60))
- self.currentTimer = self.Addon.getSetting('timer_amount')
+
+ def cleanLibrary(self,cronJob):
+ #check which database we're in
+ media_type = 'video'
+ if(cronJob.command.find('music') != -1):
+ media_type = 'music'
+
+ #check if we should verify paths
+ if(self.Addon.getSetting("verify_paths") == 'true'):
+ response = eval(xbmc.executeJSONRPC('{ "jsonrpc" : "2.0", "method"
: "Files.GetSources", "params":{"media":"' + media_type + '"}, "id": 1}'))
+ for source in response['result']['sources']:
+ if not xbmcvfs.exists(source['file']):
+ #let the user know this failed, if they subscribe to
notifications
+ if(self.Addon.getSetting('notify_next_run') == 'true'):
+ xbmc.executebuiltin("Notification(Error Cleaning
Databse,Source " + source['label'] + " does not exist,4000," +
xbmc.translatePath(self.addondir + "/resources/images/clock.png") + ")")
+
+ self.log("Path " + source['file'] + " does not exist")
+ return
+
+ #run the clean operation
+ self.log("Cleaning Database")
+ xbmc.executebuiltin("CleanLibrary(" + media_type + ")")
+
+ def readLastRun(self):
+
+ try:
+ f = open(xbmc.translatePath(self.datadir + "last_run.txt"),"r")
+ self.last_run = float(f.read())
+ f.close()
+ except IOError:
+ #the file doesn't exist, most likely first time running
+ self.last_run = 0
+
+ def writeLastRun(self):
+ #create the addon folder if it doesn't exist
+ if(not os.path.exists(xbmc.translatePath(self.datadir))):
+ os.makedirs(xbmc.translatePath(self.datadir))
+
+ f = open(xbmc.translatePath(self.datadir + "last_run.txt"),"w")
+
+ #write out the value for the last time the program ran
+ f.write(str(self.last_run));
+ f.close();
+
+ def scanRunning(self):
+ #check if any type of scan is currently running
+ if(xbmc.getCondVisibility('Library.IsScanningVideo') or
xbmc.getCondVisibility('Library.IsScanningMusic')):
+ return True
else:
- if self.Addon.getSetting("cron_expression") != self.currentTimer:
- cronExp =
croniter(self.Addon.getSetting("cron_expression"),datetime.now())
- self.showNotify(cronExp.get_next(float))
- self.currentTimer = self.Addon.getSetting("cron_expression")
+ return False
+ def waitForScan(self):
+ #what for scan to start
+ time.sleep(2)
+
+ while(self.scanRunning()):
+ time.sleep(5)
+
def log(self,message):
xbmc.log('service.libraryautoupdate: ' + message)
+
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=daec02cb0d85578646852320fca22491408cab6d
commit daec02cb0d85578646852320fca22491408cab6d
Author: amet <[email protected]>
Date: Sun Apr 1 17:37:28 2012 +0400
[script.cu.lyrics] -v 2.0.4
- added lyricwiki service
diff --git a/script.cu.lyrics/addon.xml b/script.cu.lyrics/addon.xml
index 8364468..c6e9af7 100644
--- a/script.cu.lyrics/addon.xml
+++ b/script.cu.lyrics/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.cu.lyrics"
name="CU Lyrics"
- version="2.0.3"
+ version="2.0.4"
provider-name="Amet">
<requires>
<import addon="xbmc.python" version="2.0"/>
@@ -9,9 +9,11 @@
<extension point="xbmc.python.lyrics"
library="default.py" />
<extension point="xbmc.addon.metadata">
+ <summary lang="bg">CU лиÑики</summary>
<summary lang="en">CU Lyrics</summary>
<summary lang="hu">CU Lyrics dalszöveg</summary>
<summary lang="de">CU Lyrics</summary>
+ <description lang="bg">ТÑÑÑи, ÑÐ²Ð°Ð»Ñ Ð¸ изобÑазÑва
лиÑики Ð¾Ñ LyricWIKI.org. СвалениÑе лиÑики Ñе
запиÑÐ²Ð°Ñ Ð² userdata/addon_data.Lyrics. OSD бÑÑонÑÑ ÑÑÑбва
да е акÑивиÑан и да е зададен пÑÑ ÐºÑм CU
лиÑикиÑе Ð¾Ñ ÐаÑÑÑойки -> Ðблик ->
СкÑипÑове</description>
<description lang="en">Search, download and display lyrics from
LyricWIKI.org. Downloaded lyrics will be saved in userdata/addon_data.Lyrics
button on OSD needs to be activated and path set to CU Lyrics under Settings->
Skin-> Scripts </description>
<description lang="hu">Dalszövegek keresése letöltése, megjelenÃtése
a LyricWIKI.org webhelyrÅl. A letöltött dalszövegek a userdata/addon_data
mappába kerülnek. A dalszöveg OSD gombot aktiválni kell az elérési út
megadásával a BeállÃtások -> Skin -> Szkriptek alatt.</description>
<description lang="de">Suche, downloade und zeige Lyrics von
LyricWIKI.org. Heruntergeladene Lyrics werden in userdata/addon_data
gespeichert. Der Lyrics-Button muss im OSD aktiviert werden und der Pfad zu CU
Lyrics muss in den Einstellungen spezifiziert werden.</description>
diff --git a/script.cu.lyrics/changelog.txt b/script.cu.lyrics/changelog.txt
index cbf5b71..8f50a24 100644
--- a/script.cu.lyrics/changelog.txt
+++ b/script.cu.lyrics/changelog.txt
@@ -1,3 +1,6 @@
+2.0.4
+- added lyricwiki service
+
2.0.3
- clean lyrics before saving
- clean search string further for better matching, thx DDDamian for that
diff --git a/script.cu.lyrics/resources/language/English/strings.xml
b/script.cu.lyrics/resources/language/English/strings.xml
index 6afbc22..506c538 100644
--- a/script.cu.lyrics/resources/language/English/strings.xml
+++ b/script.cu.lyrics/resources/language/English/strings.xml
@@ -10,6 +10,7 @@
<string id="30005">File</string>
<string id="30006">Lyricsmode.com API</string>
<string id="30007">Lyricstime.com API</string>
+ <string id="30008">Lyricwiki.com API</string>
<!-- Settings -->
<string id="30100">Smooth Scrolling</string>
-----------------------------------------------------------------------
Summary of changes:
script.cu.lyrics/addon.xml | 4 +-
script.cu.lyrics/changelog.txt | 3 +
.../resources/language/Bulgarian/strings.xml | 26 ++
.../resources/language/English/strings.xml | 1 +
.../lib/scrapers/{ => lyricwiki}/__init__.py | 0
.../lib/scrapers/lyricwiki/lyricsScraper.py | 47 +++
service.libraryautoupdate/README.txt | 21 +-
service.libraryautoupdate/addon.xml | 6 +-
service.libraryautoupdate/changelog.txt | 18 +-
service.libraryautoupdate/disclaimer.py | 8 +
service.libraryautoupdate/manual.py | 13 +-
.../{icon.png => resources/images/clock.png} | Bin 134394 -> 126059
bytes
.../resources/language/English/strings.xml | 22 +-
service.libraryautoupdate/resources/settings.xml | 31 ++-
service.libraryautoupdate/service.py | 395 +++++++++++++-------
15 files changed, 434 insertions(+), 161 deletions(-)
create mode 100644 script.cu.lyrics/resources/language/Bulgarian/strings.xml
copy script.cu.lyrics/resources/lib/scrapers/{ => lyricwiki}/__init__.py (100%)
create mode 100644
script.cu.lyrics/resources/lib/scrapers/lyricwiki/lyricsScraper.py
create mode 100644 service.libraryautoupdate/disclaimer.py
copy service.libraryautoupdate/{icon.png => resources/images/clock.png} (55%)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons