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 runProgram(self): # a one-time catch for the startup delay if (utils.getSettingInt("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( ) + utils.getSettingInt("startup_delay") * 60 count = count + 1 utils.log(str(utils.getSettingInt('startup_delay'))) # display upgrade messages if they exist if (utils.getSettingInt('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 (True): # don't check unless new minute if (time.time() > self.last_run + 60): self.readLastRun() self.evalSchedules() # calculate the sleep time (next minute) now = datetime.now() if (self.monitor.waitForAbort(60 - now.second)): break # clean up monitor on exit 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 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 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')) 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 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 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 start(self): # display upgrade messages if they exist if (utils.getSettingInt('upgrade_notes') < UPGRADE_INT): xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30132)) utils.setSetting('upgrade_notes', str(UPGRADE_INT)) # 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.restore() while (not self.monitor.abortRequested()): if (self.enabled): # scheduler is still on now = time.time() if (self.next_run <= now): progress_mode = utils.getSettingInt('progress_mode') self.doScheduledBackup(progress_mode) # check if we should shut the computer down if (utils.getSettingBool("cron_shutdown")): # 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 __init__(self): self.monitor = UpdateMonitor(update_method = self.settingsChanged) self.enabled = utils.getSetting("enable_scheduler") self.next_run = 0 self.update_m3u = False updater_path = os.path.join(xbmc.translatePath('special://userdata'), 'addon_data/service.iptvsubs2pvriptvsimple') if not os.path.isdir(updater_path): try: os.mkdir(updater_path) except: pass try: self.iptvsubs_addon = xbmcaddon.Addon('plugin.video.ruyaiptv') utils.setSetting("pluginmissing", "false") except: utils.log("Failed to find iptvsubs addon") self.iptvsubs_addon = None utils.setSetting("pluginmissing", "true") try: self.pvriptvsimple_addon = xbmcaddon.Addon('pvr.iptvsimple') except: utils.log("Failed to find pvr.iptvsimple addon") self.pvriptvsimple_addon = None
def writeLastRun(self): utils.setSetting('last_run',str(self.last_run))
import resources.lib.utils as utils utils.log("updating settings", xbmc.LOGDEBUG) if (len(sys.argv) > 1): for arg in sys.argv: #make sure it is a key/value pair if "=" in arg: splitString = arg.split('=') utils.log(splitString[0]) utils.setSetting(splitString[0], splitString[1])
def updateM3u(self): if self.rocketstreams_addon is None: utils.log("rocketstreams addon missing") return if self.pvriptvsimple_addon is None: utils.log("pvriptvsimple addon missing") return utils.log("Updating m3u file") username = self.rocketstreams_addon.getSetting('kasutajanimi') password = self.rocketstreams_addon.getSetting('salasona') updater_path = os.path.join(xbmc.translatePath('special://userdata'), 'addon_data/plugin.video.rocketstreams') cm_path = os.path.join( xbmc.translatePath('special://home'), 'addons/service.rocketstreamsEpgUpdate/channel_guide_map.txt') channel_map = {} if os.path.isfile(cm_path): utils.log('Adding mapped guide ids') with open(cm_path) as f: for line in f: channel_name, guide_id = line.rstrip().split("\t") channel_map[channel_name] = guide_id panel_url = "http://stream-two.doc123.nl:8000/panel_api.php?username={0}&password={1}".format( username, password) u = urllib2.urlopen(panel_url) j = json.loads(u.read()) if j['user_info']['auth'] == 0: utils.showNotification("EPG Updater", "Error: Couldn't login to rocketstreams") self.enabled = False utils.setSetting("enable_scheduler", "False") return Channel = namedtuple( 'Channel', ['tvg_id', 'tvg_name', 'tvg_logo', 'group_title', 'channel_url']) channels = [] group_idx = {} for idx, group in enumerate(self.groups): group_idx[group] = idx for ts_id, info in j["available_channels"].iteritems(): channel_url = "http://stream-two.doc123.nl:8000/live/{0}/{1}/{2}.ts".format( username, password, ts_id) tvg_id = "" tvg_name = info['name'] if tvg_name.endswith(' - NEW'): tvg_name = tvg_name[:-6] #if info['epg_channel_id'] and info['epg_channel_id'].endswith(".com"): # tvg_id = info['epg_channel_id'] if tvg_name in channel_map: tvg_id = 'tvg-id="{0}"'.format(channel_map[tvg_name]) else: tvg_id = "" tvg_id = "" tvg_logo = "" #if info['stream_icon']: # tvg_logo = info['stream_icon'] group_title = info['category_name'] if group_title == None: group_title = 'None' channels.append( Channel(tvg_id, tvg_name, tvg_logo, group_title, channel_url)) wanted_channels = [c for c in channels if c.group_title in self.groups] wanted_channels.sort(key=lambda c: "{0}-{1}".format( group_idx[c.group_title], c.tvg_name)) with open("{0}/rocketstreams.m3u".format(updater_path), "w") as m3u_f: m3u_f.write("#EXTM3U\n") for c in wanted_channels: m3u_f.write( '#EXTINF:-1 tvg-name="{0}" {1} tvg-logo="{2}" group-title="{3}",{0}\n{4}\n' .format(c.tvg_name, c.tvg_id, c.tvg_logo, c.group_title, c.channel_url)) self.checkAndUpdatePVRIPTVSetting("epgCache", "false") self.checkAndUpdatePVRIPTVSetting("epgPathType", "0") self.checkAndUpdatePVRIPTVSetting( "epgPath", updater_path + '/rocketstreams_xmltv.xml.gz') self.checkAndUpdatePVRIPTVSetting("m3uPathType", "0") self.checkAndUpdatePVRIPTVSetting( "m3uPath", "{0}/rocketstreams.m3u".format(updater_path))
httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler) print "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER) ip.close() httpd.serve_forever() try:thread.start_new_thread(startServer()) except:pass icon = utils.addon_info('icon') turtle_mode = False utils.setSetting('ver',str(xbmcaddon.Addon(id='torrent.hunter').getAddonInfo('version'))) def log(message): with open(xbmc.translatePath('special://profile/addon_data/torrent.hunter/log.txt'), 'a') as logfile: logfile.write('\n\n' + message + '\n\n') #run the program if utils.getSetting('waitingForPlayerStop') == 'true': log('Still waiting for player to stop') print 'Still waiting for player to stop' sys.exit() while xbmc.Player().isPlaying(): print 'waiting for player to stop' utils.setSetting('waitingForPlayerStop', 'true')
import resources.lib.utils as utils utils.log("updating settings",xbmc.LOGDEBUG) if(len(sys.argv) > 1): for arg in sys.argv: #make sure it is a key/value pair if "=" in arg: splitString = arg.split('=') utils.log(splitString[0]) utils.setSetting(splitString[0],splitString[1])