def onStart(self): #check if Xbian is upgrading if os.path.isfile('/var/lock/.upgrades') : if xbianConfig('updates','progress')[0] == '1': dlg = dialogWait('XBian Update','Please wait while updating') dlg.show() while not self.StopRequested and xbianConfig('updates','progress')[0] == '1': xbmc.sleep(2000) dlg.close() if self.StopRequested : return xbmc.executebuiltin("Notification(%s,%s)"%('XBian Upgrade','XBian was updated successfully')) os.remove('/var/lock/.upgrades') #check is packages is updating if os.path.isfile('/var/lock/.packages') : if xbianConfig('updates','progress')[0] == '1': dlg = dialogWait('XBian Update','Please wait while updating') dlg.show() while not self.StopRequested and xbianConfig('updates','progress')[0] == '1': xbmc.sleep(2000) dlg.close() if self.StopRequested : return xbmc.executebuiltin("Notification(%s,%s)"%('Package Update','Package was updated successfully')) os.remove('/var/lock/.packages') #for those one who deactivate its screensaver, force check every 10 days if getSetting('lastupdatecheck') != None and getSetting('lastupdatecheck') < datetime.now() - timedelta(days=10): self.onScreensaverActivated() self.onScreensaverDeactivated() while not self.StopRequested: #End if XBMC closes xbmc.sleep(100) #Repeat (ms)
def runProgram(self): #a one-time catch for the startup delay if(int(utils.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(utils.getSetting("startup_delay")) * 60 count = count + 1 #program has started, check if we should show a notification self.showNotify() while(not xbmc.abortRequested): #don't check unless new minute if(time.time() > self.last_run + 60): self.readLastRun() self.evalSchedules() xbmc.sleep(self.sleep_time) #clean up monitor on exit del self.monitor
def cleanLibrary(self,media_type): #check if we should verify paths if(utils.getSetting("verify_paths") == 'true'): response = eval(xbmc.executeJSONRPC('{ "jsonrpc" : "2.0", "method" : "Files.GetSources", "params":{"media":"' + media_type + '"}, "id": 1}')) if(response.has_key('error')): utils.log("Error " + response['error']['data']['method'] + " - " + response['error']['message'],xbmc.LOGDEBUG) return for source in response['result']['sources']: if not self._sourceExists(source['file']): #let the user know this failed, if they subscribe to notifications if(utils.getSetting('notify_next_run') == 'true'): utils.showNotification(utils.getString(30050),"Source " + source['label'] + " does not exist") utils.log("Path " + source['file'] + " does not exist") return #also check if we should verify with user first if(utils.getSetting('user_confirm_clean') == 'true'): #user can decide 'no' here and exit this runClean = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30052),utils.getString(30053)) if(not runClean): return #run the clean operation utils.log("Cleaning Database") xbmc.executebuiltin("CleanLibrary(" + media_type + ")") #write last run time, will trigger notifications self.writeLastRun()
def start(self): #check if a backup should be resumed resumeRestore = self._resumeCheck() if (resumeRestore): restore = XbmcBackup() restore.selectRestore(self.restore_point) #skip the advanced settings check restore.skipAdvanced() restore.run(XbmcBackup.Restore) while (not xbmc.abortRequested): if (self.enabled == "true"): #scheduler is still on now = time.time() if (self.next_run <= now): progress_mode = int(utils.getSetting('progress_mode')) self.doScheduledBackup(progress_mode) #check if we should shut the computer down if (utils.getSetting("cron_shutdown") == 'true'): #wait 10 seconds to make sure all backup processes and files are completed time.sleep(10) xbmc.executebuiltin('ShutDown()') else: #find the next run time like normal self.findNextRun(now) xbmc.sleep(500) #delete monitor to free up memory del self.monitor
def start(self): #check if a backup should be resumed resumeRestore = self._resumeCheck() if(resumeRestore): restore = XbmcBackup() restore.selectRestore(self.restore_point) #skip the advanced settings check restore.skipAdvanced() restore.run(XbmcBackup.Restore) while(not xbmc.abortRequested): if(self.enabled == "true"): #scheduler is still on now = time.time() if(self.next_run <= now): if(utils.getSetting('run_silent') == 'false'): utils.showNotification(utils.getString(30053)) #run the job in backup mode, hiding the dialog box backup = XbmcBackup() backup.run(XbmcBackup.Backup,True) #check if we should shut the computer down if(utils.getSetting("cron_shutdown") == 'true'): #wait 10 seconds to make sure all backup processes and files are completed time.sleep(10) xbmc.executebuiltin('ShutDown()') else: #find the next run time like normal self.findNextRun(now) xbmc.sleep(500)
def __init__(self): self.monitor = UpdateMonitor(update_method = self.settingsChanged) self.enabled = utils.getSetting("enable_scheduler") self.next_run_path = xbmc.translatePath(utils.data_dir()) + 'next_run.txt' if(self.enabled == "true"): nr = 0 if(xbmcvfs.exists(self.next_run_path)): fh = xbmcvfs.File(self.next_run_path) try: #check if we saved a run time from the last run nr = float(fh.read()) except ValueError: nr = 0 fh.close() #if we missed and the user wants to play catch-up if(0 < nr <= time.time() and utils.getSetting('schedule_miss') == 'true'): utils.log("scheduled backup was missed, doing it now...") progress_mode = int(utils.getSetting('progress_mode')) if(progress_mode == 0): progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar self.doScheduledBackup(progress_mode) self.setup()
def settingsChanged(self): utils.log("Settings changed - update") old_settings = utils.refreshAddon() current_enabled = utils.getSetting("enable_scheduler") install_keyboard_file = utils.getSetting("install_keyboard_file") if install_keyboard_file == 'true': self.installKeyboardFile() utils.setSetting('install_keyboard_file', 'false') # Return since this is going to be run immediately again return # Update m3u file if wanted groups has changed old_groups = self.groups self.updateGroups() if self.groups != old_groups or old_settings.getSetting("username") != utils.getSetting("username") or old_settings.getSetting("password") != utils.getSetting("password") or old_settings.getSetting("mergem3u_fn") != utils.getSetting("merge3mu_fn") or old_settings.getSetting("mergem3u") != utils.getSetting("mergem3u"): self.update_m3u = True if old_settings.getSetting("timezone") != utils.getSetting("timezone"): if self.pvriptvsimple_addon: utils.log("Changing offset") self.checkAndUpdatePVRIPTVSetting("epgTimeShift", utils.getSetting("timezone")) if(self.enabled == "true"): #always recheck the next run time after an update utils.log('recalculate start time , after settings update') self.findNextRun(time.time())
def start(self): #check if a backup should be resumed resumeRestore = self._resumeCheck() if(resumeRestore): restore = XbmcBackup() restore.selectRestore(self.restore_point) #skip the advanced settings check restore.skipAdvanced() restore.run(XbmcBackup.Restore) while(not xbmc.abortRequested): if(self.enabled == "true"): #scheduler is still on now = time.time() if(self.next_run <= now): progress_mode = int(utils.getSetting('progress_mode')) self.doScheduledBackup(progress_mode) #check if we should shut the computer down if(utils.getSetting("cron_shutdown") == 'true'): #wait 10 seconds to make sure all backup processes and files are completed time.sleep(10) xbmc.executebuiltin('ShutDown()') else: #find the next run time like normal self.findNextRun(now) xbmc.sleep(500) #delete monitor to free up memory del self.monitor
def onScreensaverActivated(self): print 'screensaver activated' if not xbmc.Player().isPlaying() and ( getSetting('lastupdatecheck') == None or getSetting('lastupdatecheck') < datetime.now() - timedelta(days=1)): print 'XBian : Checking for update' #check if new upgrade avalaible rc = xbianConfig('updates', 'list', 'upgrades') if rc and rc[0] == '-3': rctmp = xbianConfig('updates', 'updatedb') if rctmp and rctmp[0] == '1': rc = xbianConfig('updates', 'list', 'upgrades') else: rc[0] = '0' if rc and rc[0] not in ('0', '-2'): retval = rc[0].split(';') self.xbianUpdate = retval[3] #check if new update package avalaible rc = xbianConfig('updates', 'list', 'packages') if rc and rc[0] == '-3': rctmp = xbianConfig('updates', 'updatedb') if rctmp and rctmp[0] == '1': rc = xbianConfig('updates', 'list', 'packages') else: rc[0] = '0' if rc and rc[0] not in ('0', '-2'): self.packageUpdate = True setSetting('lastupdatecheck', datetime.now())
def runProgram(self): #a one-time catch for the startup delay if (int(utils.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( utils.getSetting("startup_delay")) * 60 count = count + 1 #display upgrade messages if they exist #if(int(utils.getSetting('upgrade_notes')) < UPGRADE_INT): # xbmcgui.Dialog().ok(utils.getString(30000),utils.getString(30030)) # utils.setSetting('upgrade_notes',str(UPGRADE_INT)) #program has started, check if we should show a notification self.showNotify() while (not xbmc.abortRequested): #don't check unless new minute if (time.time() > self.last_run + 60): self.readLastRun() self.evalSchedules() xbmc.sleep(self.sleep_time) #clean up monitor on exit del self.monitor
def __init__(self): self.monitor = UpdateMonitor(update_method=self.settingsChanged) self.enabled = utils.getSetting("enable_scheduler") self.next_run_path = xbmc.translatePath( utils.data_dir()) + 'next_run.txt' if (self.enabled == "true"): nr = 0 if (xbmcvfs.exists(self.next_run_path)): fh = xbmcvfs.File(self.next_run_path) try: #check if we saved a run time from the last run nr = float(fh.read()) except ValueError: nr = 0 fh.close() #if we missed and the user wants to play catch-up if (0 < nr <= time.time() and utils.getSetting('schedule_miss') == 'true'): utils.log("scheduled backup was missed, doing it now...") progress_mode = int(utils.getSetting('progress_mode')) if (progress_mode == 0): progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar self.doScheduledBackup(progress_mode) self.setup()
def start(self): while(not xbmc.abortRequested): current_enabled = utils.getSetting("enable_scheduler") if(current_enabled == "true" and self.enabled == "false"): #scheduler was just turned on self.enabled = current_enabled self.setup() elif (current_enabled == "false" and self.enabled == "true"): #schedule was turn off self.enabled = current_enabled elif(self.enabled == "true"): #scheduler is still on now = time.time() if(self.next_run <= now): if(utils.getSetting('run_silent') == 'false'): utils.showNotification(utils.getString(30053)) #run the job in backup mode, hiding the dialog box backup = XbmcBackup() backup.run(XbmcBackup.Backup,True) self.findNextRun(now) time.sleep(10)
def evalSchedules(self): if (not self.lock): now = time.time() count = 0 tempLastRun = self.last_run while count < len(self.schedules): cronJob = self.schedules[count] if (cronJob.next_run <= now): if (xbmc.Player().isPlaying() == False or utils.getSetting("run_during_playback") == "true"): if (utils.getSetting('run_on_idle') == 'false' or (utils.getSetting('run_on_idle') == 'true' and self.monitor.screensaver_running)): #check for valid network connection if (self._networkUp()): #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 utils.log(cronJob.name + " paused due to playback") elif (self.scanRunning() == False): #run the command for this job utils.log(cronJob.name) if (cronJob.timer_type == 'xbmc'): xbmc.executebuiltin(cronJob.command) else: self.cleanLibrary(cronJob.command) #find the next run time cronJob.next_run = self.calcNextRun( cronJob.expression, now) self.schedules[count] = cronJob elif (self.scanRunning() == True): self.schedules[count].next_run = now + 60 utils.log( "Waiting for other scan to finish") else: utils.log("Network down, not running") else: utils.log("Skipping scan, only run when idle") else: self.schedules[count].on_delay = True utils.log("Player is running, wait until finished") count = count + 1 #write last run time now = time.time() self.last_run = now - (now % 60)
def parseSchedule(self): schedule_type = int(utils.getSetting("schedule_interval")) cron_exp = utils.getSetting("cron_schedule") if self.schedule_time: hour, minute = self.schedule_time.split(':') hour = int(hour) minute = int(minute) cron_exp = str(minute) + ' ' + str(hour) + ' * * *' return cron_exp
def evalSchedules(self): if not self.lock: now = time.time() count = 0 tempLastRun = self.last_run while count < len(self.schedules): cronJob = self.schedules[count] if cronJob.next_run <= now: if xbmc.Player().isPlaying() == False or utils.getSetting("run_during_playback") == "true": if utils.getSetting("run_on_idle") == "false" or ( utils.getSetting("run_on_idle") == "true" and self.monitor.screensaver_running ): # check for valid network connection if self._networkUp(): # 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 utils.log(cronJob.name + " paused due to playback") elif self.scanRunning() == False: # run the command for this job utils.log(cronJob.name) if cronJob.timer_type == "xbmc": xbmc.executebuiltin(cronJob.command) else: self.cleanLibrary(cronJob.command) # find the next run time cronJob.next_run = self.calcNextRun(cronJob.expression, now) self.schedules[count] = cronJob elif self.scanRunning() == True: self.schedules[count].on_delay = True utils.log("Waiting for other scan to finish") else: utils.log("Network down, not running") else: utils.log("Skipping scan, only run when idle") else: self.schedules[count].on_delay = True utils.log("Player is running, wait until finished") count = count + 1 # write last run time now = time.time() self.last_run = now - (now % 60)
def checkTimer(self, settingName): result = "" # figure out if using standard or advanced timer if utils.getSetting(settingName + "_advanced_timer") == "true": # copy the expression result = utils.getSetting(settingName + "_cron_expression") else: result = "0 */" + str(self.timer_amounts[utils.getSetting(settingName + "_timer")]) + " * * *" return result
def checkTimer(self,settingName): result = '' #figure out if using standard or advanced timer if(utils.getSetting(settingName + '_advanced_timer') == 'true'): #copy the expression result = utils.getSetting(settingName + "_cron_expression") else: result = '0 */' + str(self.timer_amounts[utils.getSetting(settingName + "_timer")]) + ' * * *' return result
def start(self): #check if a backup should be resumed resumeRestore = self._resumeCheck() if(resumeRestore): restore = XbmcBackup() restore.selectRestore(self.restore_point) #skip the advanced settings check restore.skipAdvanced() restore.run(XbmcBackup.Restore) while(not xbmc.abortRequested): if(self.enabled == "true"): #scheduler is still on now = time.time() if(self.next_run <= now): progress_mode = int(utils.getSetting('progress_mode')) if(progress_mode != 2): utils.showNotification(utils.getString(30053)) backup = XbmcBackup() if(backup.remoteConfigured()): if(int(utils.getSetting('progress_mode')) in [0,1]): backup.run(XbmcBackup.Backup,True) else: backup.run(XbmcBackup.Backup,False) #check if this is a "one-off" if(int(utils.getSetting("schedule_interval")) == 0): #disable the scheduler after this run self.enabled = "false" utils.setSetting('enable_scheduler','false') else: utils.showNotification(utils.getString(30045)) #check if we should shut the computer down if(utils.getSetting("cron_shutdown") == 'true'): #wait 10 seconds to make sure all backup processes and files are completed time.sleep(10) xbmc.executebuiltin('ShutDown()') else: #find the next run time like normal self.findNextRun(now) xbmc.sleep(500) #delete monitor to free up memory del self.monitor
def start(self): #check if a backup should be resumed resumeRestore = self._resumeCheck() if (resumeRestore): restore = XbmcBackup() restore.selectRestore(self.restore_point) #skip the advanced settings check restore.skipAdvanced() restore.run(XbmcBackup.Restore) while (not xbmc.abortRequested): if (self.enabled == "true"): #scheduler is still on now = time.time() if (self.next_run <= now): progress_mode = int(utils.getSetting('progress_mode')) if (progress_mode != 2): utils.showNotification(utils.getString(30053)) backup = XbmcBackup() if (backup.remoteConfigured()): if (int(utils.getSetting('progress_mode')) in [0, 1]): backup.run(XbmcBackup.Backup, True) else: backup.run(XbmcBackup.Backup, False) #check if this is a "one-off" if (int(utils.getSetting("schedule_interval")) == 0): #disable the scheduler after this run self.enabled = "false" utils.setSetting('enable_scheduler', 'false') else: utils.showNotification(utils.getString(30045)) #check if we should shut the computer down if (utils.getSetting("cron_shutdown") == 'true'): #wait 10 seconds to make sure all backup processes and files are completed time.sleep(10) xbmc.executebuiltin('ShutDown()') else: #find the next run time like normal self.findNextRun(now) xbmc.sleep(500) #delete monitor to free up memory del self.monitor
def playStarted(self): if(self.playerMonitor.isPlayingVideo() and utils.getSetting('monitor_video') == 'true'): videoTag = self.playerMonitor.getVideoInfoTag() utils.log("Logging: " + videoTag.getTitle(),xbmc.LOGDEBUG) self.historyDB.insert(("video",videoTag.getTitle(),self.playerMonitor.getPlayingFile(),int(time.time()))) elif(self.playerMonitor.isPlayingAudio() and utils.getSetting('monitor_music') == 'true'): audioTag = self.playerMonitor.getMusicInfoTag() utils.log("Logging: " + audioTag.getTitle(),xbmc.LOGDEBUG) self.historyDB.insert(('audio',audioTag.getTitle(),self.playerMonitor.getPlayingFile(),int(time.time())))
def run(self): mode = xbmcgui.Dialog().select(utils.getString(30010),[utils.getString(30011),utils.getString(30012)]) copyComplete = False if(mode == self.REMOTE_MODE): copyComplete = self._copyFile(utils.getSetting('remote_filename')) elif(mode == self.LOCAL_MODE): copyComplete = self._copyFile(utils.getSetting('local_filename')) if(copyComplete): #prompt the user to restart xbmc restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30010),"",utils.getString(30013)) if(restartXbmc): xbmc.restart();
def onScreensaverActivated(self): print 'screensaver activated' if not xbmc.Player().isPlaying() and (getSetting('lastupdatecheck') == None or getSetting('lastupdatecheck') < datetime.now() - timedelta(days=1)): print 'XBian : Checking for update' #check if new upgrade avalaible rc =xbianConfig('updates','list','upgrades') if rc and rc[0] == '-3' : rctmp = xbianConfig('updates','updatedb') if rctmp and rctmp[0] == '1' : rc =xbianConfig('updates','list','upgrades') else : rc[0]= '0' if rc and rc[0] not in ('0','-2') : retval = rc[0].split(';') self.xbianUpdate = retval[3] #check if new update package avalaible rc =xbianConfig('updates','list','packages') if rc and rc[0] == '-3' : rctmp = xbianConfig('updates','updatedb') if rctmp and rctmp[0] == '1' : rc =xbianConfig('updates','list','packages') else : rc[0]= '0' if rc and rc[0] not in ('0','-2') : self.packageUpdate = True setSetting('lastupdatecheck',datetime.now())
def findNextRun(self, now): progress_mode = int(utils.getSetting('progress_mode')) #find the cron expression and get the next run time cron_exp = self.parseSchedule() cron_ob = croniter(cron_exp, datetime.datetime.fromtimestamp(now)) new_run_time = cron_ob.get_next(float) if (new_run_time != self.next_run): self.next_run = new_run_time utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime( '%m-%d-%Y %H:%M')) #write the next time to a file fh = xbmcvfs.File(self.next_run_path, 'w') fh.write(str(self.next_run)) fh.close() #only show when not in silent mode if (progress_mode != 2): utils.showNotification( utils.getString(30081) + " " + datetime.datetime.fromtimestamp(self.next_run).strftime( '%m-%d-%Y %H:%M'))
def parseSchedule(self): schedule_type = int(utils.getSetting("schedule_interval")) cron_exp = utils.getSetting("cron_schedule") hour_of_day = utils.getSetting("schedule_time") hour_of_day = int(hour_of_day[0:2]) if (schedule_type == 0 or schedule_type == 1): #every day cron_exp = "0 " + str(hour_of_day) + " * * *" elif (schedule_type == 2): #once a week day_of_week = utils.getSetting("day_of_week") cron_exp = "0 " + str(hour_of_day) + " * * " + day_of_week elif (schedule_type == 3): #first day of month cron_exp = "0 " + str(hour_of_day) + " 1 * *" return cron_exp
def parseSchedule(self): schedule_type = int(utils.getSetting("schedule_interval")) cron_exp = utils.getSetting("cron_schedule") hour_of_day = utils.getSetting("schedule_time") hour_of_day = int(hour_of_day[0:2]) if(schedule_type == 0 or schedule_type == 1): #every day cron_exp = "0 " + str(hour_of_day) + " * * *" elif(schedule_type == 2): #once a week day_of_week = utils.getSetting("day_of_week") cron_exp = "0 " + str(hour_of_day) + " * * " + day_of_week elif(schedule_type == 3): #first day of month cron_exp = "0 " + str(hour_of_day) + " 1 * *" return cron_exp
def __init__(self): utils.log("Grab Fanart Service Started") #setup the window and file list self.WINDOW = xbmcgui.Window(10000) self.xbmc_tv = list() self.xbmc_movies = list() self.xbmc_music = list() #let XBMC know the script is not ready yet self.WINDOW.setProperty('script.grab.fanart.Ready',"") #start populating the arrays right away - don't use threads here if(utils.getSetting('mode') == '' or utils.getSetting('mode') == 'random'): self.grabRandom() else: self.grabRecent() self.refresh_media = time() + (60 * 60) #refresh again in 60 minutes
def doScheduledBackup(self,progress_mode): if(progress_mode != 2): utils.showNotification(utils.getString(30053)) backup = XbmcBackup() if(backup.remoteConfigured()): if(int(utils.getSetting('progress_mode')) in [0,1]): backup.run(XbmcBackup.Backup,True) else: backup.run(XbmcBackup.Backup,False) #check if this is a "one-off" if(int(utils.getSetting("schedule_interval")) == 0): #disable the scheduler after this run self.enabled = "false" utils.setSetting('enable_scheduler','false') else: utils.showNotification(utils.getString(30045))
def __init__(self): utils.log("Grab Fanart Service Started") #setup the window and file list self.WINDOW = xbmcgui.Window(10000) self.xbmc_tv = list() self.xbmc_movies = list() self.xbmc_music = list() #let XBMC know the script is not ready yet self.WINDOW.setProperty('script.grab.fanart.Ready', "") #start populating the arrays right away - don't use threads here if (utils.getSetting('mode') == '' or utils.getSetting('mode') == 'random'): self.grabRandom() else: self.grabRecent() self.refresh_media = time() + (60 * 60) #refresh again in 60 minutes
def doScheduledBackup(self, progress_mode): if (progress_mode != 2): utils.showNotification(utils.getString(30053)) backup = XbmcBackup() if (backup.remoteConfigured()): if (int(utils.getSetting('progress_mode')) in [0, 1]): backup.run(XbmcBackup.Backup, True) else: backup.run(XbmcBackup.Backup, False) #check if this is a "one-off" if (int(utils.getSetting("schedule_interval")) == 0): #disable the scheduler after this run self.enabled = "false" utils.setSetting('enable_scheduler', 'false') else: utils.showNotification(utils.getString(30045))
def settingsChanged(self): utils.log("Settings changed - update") utils.refreshAddon() current_enabled = utils.getSetting("enable_scheduler") install_keyboard_file = utils.getSetting("install_keyboard_file") if install_keyboard_file == 'true': self.installKeyboardFile() utils.setSetting('install_keyboard_file', 'false') # Return since this is going to be run immediately again return # Update m3u file if wanted groups has changed old_groups = self.groups self.updateGroups() if self.groups != old_groups: self.update_m3u = True if (self.enabled == "true"): #always recheck the next run time after an update utils.log('recalculate start time , after settings update') self.findNextRun(time.time())
def _delete(self,id): #check if we need PIN confirmation to do this if(utils.getSetting('require_pin_on_delete') == 'true'): user_try = xbmcgui.Dialog().numeric(0,'PIN Required') if(self.settings.checkPIN(user_try)): self.historyDB.delete(id) xbmc.executebuiltin('Container.Refresh') else: xbmcgui.Dialog().ok('Error','Incorrect PIN') else: self.historyDB.delete(id) xbmc.executebuiltin('Container.Refresh')
def updateGroups(self): self.groups = [] for group in [ "USA", "CAN", "UK", "SPORTS", "FOR ADULTS", "PUNJABI", "PAKISTANI", "HINDI", "KIDS", "MALAYALAM", "TELUGU", "BRASIL", "MARATHI", "GUJARATI", "SERBIA", "SPANISH", "ARABIC", "FILIPINO", "BANGLA", "SINHALA", "CRICKET", "AFGHANISTAN", "KANNADA", "TAMIL", "NEPALI", "AFRICAN", "ITALY", "CARRIBEAN", "GREECE", "ROMANIAN", "CZ&SLOVAK", "MOVIE CH/HBO PPV", "POLISH", "PORTUGUESE", "NFL", "RUSSIA/UKRAINE", "TEST" ]: if utils.getSetting(group) == 'true': self.groups.append(group)
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 utils.getSetting('notify_next_run') == 'true' and displayToScreen == True): utils.showNotification(utils.getString(30000),next_run_time.name + " - " + inWords) return inWords
def onStart(self): #check if Xbian is upgrading if os.path.isfile('/var/lock/.upgrades'): if xbianConfig('updates', 'progress')[0] == '1': dlg = dialogWait('XBian Update', 'Please wait while updating') dlg.show() while not self.StopRequested and xbianConfig( 'updates', 'progress')[0] == '1': time.sleep(2) dlg.close() if self.StopRequested: return xbmc.executebuiltin( "Notification(%s,%s)" % ('XBian Upgrade', 'XBian was updated successfully')) os.remove('/var/lock/.upgrades') #check is packages is updating if os.path.isfile('/var/lock/.packages'): if xbianConfig('updates', 'progress')[0] == '1': dlg = dialogWait('XBian Update', 'Please wait while updating') dlg.show() while not self.StopRequested and xbianConfig( 'updates', 'progress')[0] == '1': time.sleep(2) dlg.close() if self.StopRequested: return xbmc.executebuiltin( "Notification(%s,%s)" % ('Package Update', 'Package was updated successfully')) os.remove('/var/lock/.packages') #for those one who deactivate its screensaver, force check every 10 days if getSetting('lastupdatecheck') != None and getSetting( 'lastupdatecheck') < datetime.now() - timedelta(days=10): self.onScreensaverActivated() self.onScreensaverDeactivated() while not self.StopRequested: #End if XBMC closes xbmc.sleep(50000) #Repeat (ms)
def onSettingsUpdate(self): #check if a pin is required to change settings if(self.require_pin): dialog = xbmcgui.Dialog() #ask the user for their pin user_try = dialog.numeric(0,'Pin required to change settings') if(self.settings.checkPIN(user_try)): #make backup of new settings self._settingsBackup() if(utils.getSetting('require_pin_on_change') == 'false'): self.require_pin = False else: #restore the settings file self._settingsRestore() dialog.ok('Error','Incorrect PIN') else: #check this setting in case it's the one that changed if(utils.getSetting('require_pin_on_change') == 'true'): self.require_pin = True
def settingsChanged(self): current_enabled = utils.getSetting("enable_scheduler") if (current_enabled == "true" and self.enabled == "false"): #scheduler was just turned on self.enabled = current_enabled self.setup() elif (current_enabled == "false" and self.enabled == "true"): #schedule was turn off self.enabled = current_enabled if (self.enabled == "true"): #always recheck the next run time after an update self.findNextRun(time.time())
def settingsChanged(self): current_enabled = utils.getSetting("enable_scheduler") if(current_enabled == "true" and self.enabled == "false"): #scheduler was just turned on self.enabled = current_enabled self.setup() elif (current_enabled == "false" and self.enabled == "true"): #schedule was turn off self.enabled = current_enabled if(self.enabled == "true"): #always recheck the next run time after an update self.findNextRun(time.time())
def cleanLibrary(self,media_type): #check if we should verify with user first if(utils.getSetting('user_confirm_clean') == 'true'): #user can decide 'no' here and exit this runClean = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30052),line2=utils.getString(30053),autoclose=15000) if(not runClean): return #run the clean operation utils.log("Cleaning Database") xbmc.executebuiltin("CleanLibrary(" + media_type + ")") #write last run time, will trigger notifications self.writeLastRun()
def databaseUpdated(self,database): #check if we should clean the library if(utils.getSetting('clean_libraries') == 'true'): #check if should update while playing media if(xbmc.Player().isPlaying() == False or utils.getSetting("run_during_playback") == "true"): if(int(utils.getSetting("clean_timer")) == 0): #check if we should clean music, or video if((utils.getSetting('library_to_clean') == '0' or utils.getSetting('library_to_clean') == '1') and database == 'video'): self.cleanLibrary(database) if((utils.getSetting('library_to_clean') == '2' or utils.getSetting('library_to_clean') == '0') and database == 'music'): self.cleanLibrary(database) #writeLastRun will trigger notifications self.writeLastRun()
def onInit(self): print 'on inint, before xbmc onInit' xbmc.log('XBian-config : Show(onInit) XbianWindow',xbmc.LOGDEBUG) WindowSkinXml.onInit(self) print 'on inint, after xbmc onInit' #first, get all public method for category in self.categories : title = category.getTitle() xbmc.executebuiltin('Skin.SetString(%sloadingvalue,%s)'%(title,_('xbian-config.common.clicktoload'))) self.publicMethod[title] = {} self.loadingCat[title] = False for setting in category.getSettings(): public = setting.getPublicMethod() for key in public : self.publicMethod[category.getTitle()][key] = public[key] xbmc.log('XBian-config : End Show(onInit) XbianWindow',xbmc.LOGDEBUG) setvisiblecondition('advancedmode',getSetting('advancedmode')=='1')
def __init__(self): self.monitor = UpdateMonitor(update_method=self.settingsChanged) self.enabled = utils.getSetting("enable_scheduler") self.next_run = 0 self.update_m3u = False try: self.rocketstreams_addon = xbmcaddon.Addon( 'plugin.video.rocketstreams') except: utils.log("Failed to find rocketstreams addon") self.rocketstreams_addon = None try: self.pvriptvsimple_addon = xbmcaddon.Addon('pvr.iptvsimple') except: utils.log("Failed to find pvr.iptvsimple addon") self.pvriptvsimple_addon = None
def __init__(self): utils.log("Starting History Service") self.playerMonitor = HistoryPlayerMonitor(on_play_started = self.playStarted) self.updateMonitor = HistorySettingsMonitor(update_settings = self.onSettingsUpdate) #setup the database connection database = Database() database.connect() database.checkDBStructure() self.historyDB = WatchHistory(database) self.settings = DBSettings(database) if(utils.getSetting('require_pin_on_change') == 'true'): self.require_pin = True #backup the settings file self._settingsBackup()
def databaseUpdated(self, database): # check if we should clean the library if utils.getSetting("clean_libraries") == "true": # check if should update while playing media if xbmc.Player().isPlaying() == False or utils.getSetting("run_during_playback") == "true": if int(utils.getSetting("clean_timer")) == 0: # check if we should clean music, or video if ( utils.getSetting("library_to_clean") == "0" or utils.getSetting("library_to_clean") == "1" ) and database == "video": self.cleanLibrary(database) if ( utils.getSetting("library_to_clean") == "2" or utils.getSetting("library_to_clean") == "0" ) and database == "music": self.cleanLibrary(database) # writeLastRun will trigger notifications self.writeLastRun()
def onInit(self): print('on inint, before xbmc onInit') xbmc.log('XBian-config : Show(onInit) XbianWindow', xbmc.LOGDEBUG) WindowSkinXml.onInit(self) print('on inint, after xbmc onInit') # first, get all public method for category in self.categories: title = category.getTitle() xbmc.executebuiltin( 'Skin.SetString(%sloadingvalue,%s)' % ( title, _('Click to load...'))) self.publicMethod[title] = {} self.loadingCat[title] = False for setting in category.getSettings(): public = setting.getPublicMethod() for key in public: self.publicMethod[category.getTitle()][key] = public[key] xbmc.log('XBian-config : End Show(onInit) XbianWindow', xbmc.LOGDEBUG) setvisiblecondition('advancedmode', getSetting('advancedmode') == '1') setvisiblecondition('umountsnapshot', xbianConfig('mount', cmd=['sudo', 'btrfs-auto-snapshot']))
def findNextRun(self,now): progress_mode = int(utils.getSetting('progress_mode')) #find the cron expression and get the next run time cron_exp = self.parseSchedule() cron_ob = croniter(cron_exp,datetime.datetime.fromtimestamp(now)) new_run_time = cron_ob.get_next(float) if(new_run_time != self.next_run): self.next_run = new_run_time utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M')) #write the next time to a file fh = xbmcvfs.File(self.next_run_path, 'w') fh.write(str(self.next_run)) fh.close() #only show when not in silent mode if(progress_mode != 2): utils.showNotification(utils.getString(30081) + " " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
def __init__(self): self.monitor = UpdateMonitor(update_method = self.settingsChanged) self.enabled = utils.getSetting("enable_scheduler") self.next_run = 0 self.schedule_time = __addon__.getSetting("schedule_time") self.unzipPath = __addon__.getSetting("downloadPath") if 'special://' in self.unzipPath: self.realUnzipPath = xbmc.translatePath(self.unzipPath) else: self.realUnzipPath = self.unzipPath if configureSimple != 'false' : utils.log(configureSimple) self.cycleAddon('pvr.iptvsimple') self.cycleAddon('plugin.video.stalker') try: self.pvriptvsimple_addon = xbmcaddon.Addon('pvr.iptvsimple') except: utils.log("Failed to find pvr.iptvsimple addon") self.pvriptvsimple_addon = None try: self.videostalker = xbmcaddon.Addon('plugin.video.stalker') except: utils.log("Failed to find plugin.video.stalker addon") self.pvriptvsimple_addon = None if configureStalker != 'false' : try: self.cycleAddon('pvr.stalker') self.pvrstalker_addon = xbmcaddon.Addon('pvr.stalker') except: utils.log("Failed to find pvr.stalker addon") self.pvrstalker_addon = None self.updateEpg() self.setup()
import xbmcgui import resources.lib.utils as utils from service import AutoUpdater autoUpdate = AutoUpdater() runUpdate = False if(utils.getSetting('disable_manual_prompt') == 'false'): nextRun = autoUpdate.showNotify(False) #check if we should run updates runUpdate = xbmcgui.Dialog().yesno(utils.getString(30000),utils.getString(30060) + nextRun,line2=utils.getString(30061),autoclose=6000) else: #the user has elected to skip the prompt runUpdate = True if(runUpdate): #run the program utils.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() #delete the monitor before exiting del autoUpdate.monitor
def readLastRun(self): if(self.last_run == 0): #read it in from the settings self.last_run = float(utils.getSetting('last_run'))
def run(self): command = int(self.params['command']) window = int(self.params['window']) if (command == 1): #we want to create a job self._createJob() elif (command == 2): #delete command aJob = self.cron.getJob(int(self.params['job'])) confirm = xbmcgui.Dialog().yesno( utils.getString(30007), utils.getString(30009) + " " + aJob.name) if (confirm): #delete the job self.cron.deleteJob(aJob.id) elif (command == 3): #update the name aJob = self.cron.getJob(int(self.params['job'])) aJob.name = xbmcgui.Dialog().input( utils.getString(30006) + " " + utils.getString(30002), aJob.name) self.cron.addJob(aJob) elif (command == 4): #udpate the command aJob = self.cron.getJob(int(self.params['job'])) aJob.command = xbmcgui.Dialog().input( utils.getString(30006) + " " + utils.getString(30003), aJob.command) self.cron.addJob(aJob) elif (command == 5): #update the expression aJob = self.cron.getJob(int(self.params['job'])) aJob.expression = xbmcgui.Dialog().input( utils.getString(30006) + " " + utils.getString(30004), aJob.expression) if (not self.cron.addJob(aJob)): xbmcgui.Dialog().ok(utils.getString(30000), 'Job not added, cron expression error') elif (command == 6): #update the notification setting aJob = self.cron.getJob(int(self.params['job'])) if (xbmcgui.Dialog().yesno(utils.getString(30005), utils.getString(30010))): aJob.show_notification = "true" else: aJob.show_notification = "false" self.cron.addJob(aJob) if (command != 0): #always refresh after command xbmc.executebuiltin('Container.Refresh') jobs = self.cron.getJobs(utils.getSetting('show_all')) if (window == 0): #create the default window addItem = xbmcgui.ListItem(utils.getString(30001)) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=self.context_url % (sys.argv[0], 'command=1&window=0'), listitem=addItem, isFolder=False) for j in jobs: #list each job cronItem = xbmcgui.ListItem(j.name + " - " + utils.getString(30011) + ": " + self.cron.nextRun(j)) cronItem.addContextMenuItems([ (utils.getString(30008), self.plugin_url % (sys.argv[0], 'command=0&window=1&job=' + str(j.id))), (utils.getString(30007), self.plugin_url % (sys.argv[0], 'command=2&window=0&job=' + str(j.id))) ]) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=self.context_url % (sys.argv[0], 'command=0&window=1&job=' + str(j.id)), listitem=cronItem, isFolder=True) elif (window == 1): #list the details of this job aJob = self.cron.getJob(int(self.params['job'])) name = xbmcgui.ListItem(utils.getString(30002) + ": " + aJob.name) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=self.context_url % (sys.argv[0], 'command=3&window=1&job=' + str(aJob.id)), listitem=name, isFolder=False) command = xbmcgui.ListItem( utils.getString(30003) + ": " + aJob.command) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=self.context_url % (sys.argv[0], 'command=4&window=1&job=' + str(aJob.id)), listitem=command, isFolder=False) expression = xbmcgui.ListItem( utils.getString(30004) + ": " + aJob.expression) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=self.context_url % (sys.argv[0], 'command=5&window=1&job=' + str(aJob.id)), listitem=expression, isFolder=False) showNotification = 'No' if (aJob.show_notification == 'true'): showNotification = 'Yes' notification = xbmcgui.ListItem( utils.getString(30005) + ": " + showNotification) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=self.context_url % (sys.argv[0], 'command=6&window=1&job=' + str(aJob.id)), listitem=notification, isFolder=False) xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False)
try: import pydevd pydevd.settrace('localhost', port=60678, stdoutToServer=True, stderrToServer=True) except ImportError: sys.stderr.write( "Error: " + "You must add org.python.pydev.debug.pysrc to your PYTHONPATH.") utils.showNotification('WatchedList Error', 'remote debug could not be imported.') sys.exit(1) except: utils.showNotification( 'WatchedList Error', 'remote debug in pydev is activated, but remote server not responding.' ) sys.exit(1) # Create WatchedList Class WL = WatchedList() if (not utils.getSetting("autostart") == 'true') or xbmcgui.Dialog().yesno( utils.getString(32101), utils.getString(32001)): # Check if we should run updates (only ask if autostart is on) # run the program utils.log("Update Library Manual Run.") # WL.runProgram() # function executed on autostart. For Test purpose WL.runUpdate(True) # one time update
def createSchedules(self,forceUpdate = False): utils.log("update timers") self.lock = True #lock so the eval portion does not run self.schedules = [] if(utils.getSetting('clean_libraries') == 'true'): #create clean schedule (if needed) if(int(utils.getSetting("clean_timer")) != 0): if(utils.getSetting('library_to_clean') == '0' or utils.getSetting('library_to_clean') == '1'): #video clean schedule starts at 12am by default aSchedule = CronSchedule() aSchedule.name = utils.getString(30048) aSchedule.timer_type = utils.__addon_id__ aSchedule.command = 'video' if(int(utils.getSetting("clean_timer")) == 4): aSchedule.expression = utils.getSetting("clean_video_cron_expression") else: aSchedule.expression = "0 0 " + aSchedule.cleanLibrarySchedule(int(utils.getSetting("clean_timer"))) aSchedule.next_run = self.calcNextRun(aSchedule.expression,time.time()) self.schedules.append(aSchedule) if(utils.getSetting('library_to_clean') == '2' or utils.getSetting('library_to_clean') == '0'): #music clean schedule starts at 2am by default aSchedule = CronSchedule() aSchedule.name = utils.getString(30049) aSchedule.timer_type = utils.__addon_id__ aSchedule.command = 'music' if(int(utils.getSetting("clean_timer")) == 4): aSchedule.expression = utils.getSetting("clean_music_cron_expression") else: aSchedule.expression = "0 2 " + aSchedule.cleanLibrarySchedule(int(utils.getSetting("clean_timer"))) aSchedule.next_run = self.calcNextRun(aSchedule.expression,time.time()) self.schedules.append(aSchedule) if(utils.getSetting('update_video') == 'true'): #create the video schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30004) aSchedule.command = 'UpdateLibrary(video)' aSchedule.expression = self.checkTimer('video') aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run) self.schedules.append(aSchedule) if(utils.getSetting('update_music') == 'true'): #create the music schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30005) aSchedule.command = 'UpdateLibrary(music)' aSchedule.expression = self.checkTimer('music') aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run) self.schedules.append(aSchedule) if(utils.getSetting('use_custom_1_path') == 'true'): #create a custom video path schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30020) aSchedule.command = 'UpdateLibrary(video,' + utils.getSetting('custom_1_scan_path') + ')' aSchedule.expression = self.checkTimer('custom_1') aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run) self.schedules.append(aSchedule) if(utils.getSetting('use_custom_2_path') == 'true'): #create a custom video path schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30021) aSchedule.command = 'UpdateLibrary(video,' + utils.getSetting('custom_2_scan_path') + ')' aSchedule.expression = self.checkTimer('custom_2') aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run) self.schedules.append(aSchedule) if(utils.getSetting('use_custom_3_path') == 'true'): #create a custom video path schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30022) aSchedule.command = 'UpdateLibrary(video,' + utils.getSetting('custom_3_scan_path') + ')' aSchedule.expression = self.checkTimer('custom_3') aSchedule.next_run = self.calcNextRun(aSchedule.expression,self.last_run) self.schedules.append(aSchedule) #release the lock self.lock = False #show any notifications self.showNotify(not forceUpdate)
def evalSchedules(self, manual=False): if (not self.lock): now = time.time() count = 0 player = xbmc.Player() while count < len(self.schedules): cronJob = self.schedules[count] if (cronJob.next_run <= now): if (not player.isPlaying() or utils.getSetting("run_during_playback") == "true"): # check if run on idle is checked and screen is idle - disable this on manual run if (not utils.getSettingBool('run_on_idle') or (utils.getSettingBool('run_on_idle') and (self.monitor.screensaver_running or manual))): # check for valid network connection - check sources if setting enabled if (self._networkUp() and (not utils.getSettingBool('check_sources') or (utils.getSettingBool('check_sources') and self._checkSources(cronJob)))): # check if this scan was delayed due to playback if (cronJob.on_delay): # add another minute to the delay self.schedules[count].next_run = now + 60 self.schedules[count].on_delay = False utils.log(cronJob.name + " paused due to playback") elif (not self.scanRunning()): # run the command for this job utils.log(cronJob.name) if (cronJob.timer_type == 'xbmc'): cronJob.executeCommand() else: self.cleanLibrary(cronJob) # find the next run time cronJob.next_run = self.calcNextRun( cronJob.expression, now) self.schedules[count] = cronJob elif (self.scanRunning()): self.schedules[count].next_run = now + 60 utils.log( "Waiting for other scan to finish") else: utils.log("Network down, not running") else: utils.log("Skipping scan, only run when idle") else: self.schedules[count].on_delay = True utils.log("Player is running, wait until finished") count = count + 1 # write last run time now = time.time() self.last_run = now - (now % 60)
def createSchedules(self, forceUpdate=False): utils.log("update timers") self.lock = True # lock so the eval portion does not run self.schedules = [] showDialogs = utils.getSettingBool( 'notify_next_run' ) # if the user has selected to show dialogs for library operations if (utils.getSettingBool('clean_libraries')): # create clean schedule (if needed) if (utils.getSettingInt("clean_timer") != 0): if (utils.getSettingInt('library_to_clean') == 0 or utils.getSettingInt('library_to_clean') == 1): # video clean schedule starts at 12am by default aSchedule = CronSchedule() aSchedule.name = utils.getString(30048) aSchedule.timer_type = utils.__addon_id__ aSchedule.command = { 'method': 'VideoLibrary.Clean', 'params': { 'showdialogs': showDialogs } } if (utils.getSettingInt("clean_timer") == 4): aSchedule.expression = utils.getSetting( "clean_video_cron_expression") else: aSchedule.expression = "0 0 " + aSchedule.cleanLibrarySchedule( utils.getSettingInt("clean_timer")) aSchedule.next_run = self.calcNextRun( aSchedule.expression, time.time()) self.schedules.append(aSchedule) if (utils.getSettingInt('library_to_clean') == 2 or utils.getSettingInt('library_to_clean') == 0): # music clean schedule starts at 2am by default aSchedule = CronSchedule() aSchedule.name = utils.getString(30049) aSchedule.timer_type = utils.__addon_id__ aSchedule.command = { 'method': 'AudioLibrary.Clean', 'params': { 'showdialogs': showDialogs } } if (utils.getSettingInt("clean_timer") == 4): aSchedule.expression = utils.getSetting( "clean_music_cron_expression") else: aSchedule.expression = "0 2 " + aSchedule.cleanLibrarySchedule( utils.getSettingInt("clean_timer")) aSchedule.next_run = self.calcNextRun( aSchedule.expression, time.time()) self.schedules.append(aSchedule) if (utils.getSettingBool('update_video')): utils.log("Creating timer for Video Library") # create the video schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30012) aSchedule.command = { 'method': 'VideoLibrary.Scan', 'params': { 'showdialogs': showDialogs } } aSchedule.expression = self.checkTimer('video') aSchedule.next_run = self.calcNextRun(aSchedule.expression, self.last_run) self.schedules.append(aSchedule) # add custom video paths (separate timers) customPaths = CustomPathFile('video') for aJob in customPaths.getSchedules(showDialogs): utils.log("Creating timer " + aJob.name) aJob.next_run = self.calcNextRun(aJob.expression, self.last_run) self.schedules.append(aJob) if (utils.getSettingBool('update_music')): utils.log("Creating timer for Music Library") # create the music schedule aSchedule = CronSchedule() aSchedule.name = utils.getString(30013) aSchedule.command = { 'method': 'AudioLibrary.Scan', 'params': { 'showdialogs': showDialogs } } aSchedule.expression = self.checkTimer('music') aSchedule.next_run = self.calcNextRun(aSchedule.expression, self.last_run) self.schedules.append(aSchedule) # add custom music paths (separate timers) customPaths = CustomPathFile('music') for aJob in customPaths.getSchedules(showDialogs): utils.log("Creating timer " + aJob.name) aJob.next_run = self.calcNextRun(aJob.expression, self.last_run) self.schedules.append(aJob) # release the lock self.lock = False utils.log("Created " + str(len(self.schedules)) + " schedules", xbmc.LOGDEBUG) # show any notifications self.showNotify(not forceUpdate)
def run(self): #let xbmc know the images are ready self.WINDOW.setProperty('script.grab.fanart.Ready',"true") #keep this thread alive while(not xbmc.abortRequested): if(time() >= self.refresh_prop): aVideo = None globalArt = None if(len(self.xbmc_movies) > 0): try: self.WINDOW.setProperty('script.grab.fanart.Movie.Title',self.xbmc_movies[self.movie_index].title) self.WINDOW.setProperty('script.grab.fanart.Movie.FanArt',self.xbmc_movies[self.movie_index].fan_art) self.WINDOW.setProperty('script.grab.fanart.Movie.Poster',self.xbmc_movies[self.movie_index].poster) self.WINDOW.setProperty('script.grab.fanart.Movie.Logo',self.xbmc_movies[self.movie_index].logo) self.WINDOW.setProperty('script.grab.fanart.Movie.Plot',self.xbmc_movies[self.movie_index].plot) self.WINDOW.setProperty('script.grab.fanart.Movie.Path',self.xbmc_movies[self.movie_index].path) aVideo = self.xbmc_movies[self.movie_index] globalArt = aVideo except IndexError: pass self.movie_index = self.movie_index + 1 if(self.movie_index >= len(self.xbmc_movies)): self.movie_index = 0 if(len(self.xbmc_tv) > 0): try: self.WINDOW.setProperty('script.grab.fanart.TV.Title',self.xbmc_tv[self.tv_index].title) self.WINDOW.setProperty('script.grab.fanart.TV.FanArt',self.xbmc_tv[self.tv_index].fan_art) self.WINDOW.setProperty('script.grab.fanart.TV.Poster',self.xbmc_tv[self.tv_index].poster) self.WINDOW.setProperty('script.grab.fanart.TV.Logo',self.xbmc_tv[self.tv_index].logo) self.WINDOW.setProperty('script.grab.fanart.TV.Plot',self.xbmc_tv[self.tv_index].plot) self.WINDOW.setProperty('script.grab.fanart.TV.Path',self.xbmc_tv[self.tv_index].path) #this will only have a value when "recent" is the type self.WINDOW.setProperty('script.grab.fanart.TV.Season',str(self.xbmc_tv[self.tv_index].season)) self.WINDOW.setProperty('script.grab.fanart.TV.Episode',str(self.xbmc_tv[self.tv_index].episode)) self.WINDOW.setProperty('script.grab.fanart.TV.Thumb',self.xbmc_tv[self.tv_index].thumb) #use a tv show if blank or randomly selected is = 9 (10% chance) if(aVideo == None or self.randomNum(10) == 9): aVideo = self.xbmc_tv[self.tv_index] #30% change of TV show on global if(globalArt == None or self.randomNum(3) == 2): globalArt = self.xbmc_tv[self.tv_index] except IndexError: pass self.tv_index = self.tv_index + 1 if(self.tv_index >= len(self.xbmc_tv)): self.tv_index = 0 if(aVideo != None): self.WINDOW.setProperty('script.grab.fanart.Video.Title',aVideo.title) self.WINDOW.setProperty('script.grab.fanart.Video.FanArt',aVideo.fan_art) self.WINDOW.setProperty('script.grab.fanart.Video.Poster',aVideo.poster) self.WINDOW.setProperty('script.grab.fanart.Video.Logo',aVideo.logo) self.WINDOW.setProperty('script.grab.fanart.Video.Plot',aVideo.plot) self.WINDOW.setProperty('script.grab.fanart.Video.Path',aVideo.path) if(len(self.xbmc_music) > 0): try: self.WINDOW.setProperty('script.grab.fanart.Music.Artist',self.xbmc_music[self.music_index].title) self.WINDOW.setProperty('script.grab.fanart.Music.FanArt',self.xbmc_music[self.music_index].fan_art) self.WINDOW.setProperty('script.grab.fanart.Music.Description',self.xbmc_music[self.music_index].plot) #30% of music fanart on global if(globalArt == None or self.randomNum(3) == 2): globalArt = self.xbmc_music[self.music_index] except IndexError: pass self.music_index = self.music_index + 1 if(self.music_index >= len(self.xbmc_music)): self.music_index = 0 if(globalArt != None): self.WINDOW.setProperty('script.grab.fanart.Global.Title',globalArt.title) self.WINDOW.setProperty('script.grab.fanart.Global.FanArt',globalArt.fan_art) self.WINDOW.setProperty('script.grab.fanart.Global.Logo',globalArt.logo) self.refresh_prop = time() + float(utils.getSetting("refresh")) #check if the media list should be updated if(time() >= self.refresh_media): if(utils.getSetting('mode') == 'random'): thread.start_new_thread(self.grabRandom,()) else: thread.start_new_thread(self.grabRecent,()) self.refresh_media = time() + (60 * 60) #refresh again in 60 minutes xbmc.sleep(500)