def addAutotimerFromSearchString(session, match): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer autotimer.readXml() newTimer = autotimer.defaultTimer.clone() newTimer.id = autotimer.getUniqueId() newTimer.name = match newTimer.match = '' newTimer.enabled = True session.openWithCallback( importerCallback, AutoTimerImporter, newTimer, match, # Proposed Match None, # Proposed Begin None, # Proposed End None, # Proposed Disabled None, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay None, # Proposed dirname, can we get anything useful here? [] # Proposed tags )
def addAutotimerFromSearchString(session, match): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer # Create instance if needed if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() session.openWithCallback( importerCallback, AutoTimerImporter, preferredAutoTimerComponent( autotimer.getUniqueId(), match, '', # Match True # Enabled ), match, # Proposed Match None, # Proposed Begin None, # Proposed End None, # Proposed Disabled None, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay None, # Proposed dirname, can we get anything useful here? [] # Proposed tags )
def render_POST(self, req): req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml;' ) req.setHeader('charset', 'UTF-8') autotimer.readXml(xml_string=req.args['xml'][0]) if config.plugins.autotimer.always_write_config.value: autotimer.writeXml() return self.returnResult(req, True, _("AutoTimers were changed successfully"))
def render_POST(self, req): req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml;' ) req.setHeader('charset', 'UTF-8') autotimer.readXml(xml_string=req.args['xml'][0]) if config.plugins.autotimer.always_write_config.value: autotimer.writeXml() return self.returnResult(req, True, _("AutoTimers were changed successfully."))
def addAutotimerFromService(session, service = None): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer autotimer.readXml() serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(service) match = info and info.getName(service) or "" name = match or "New AutoTimer" sref = info and info.getInfoString(service, iServiceInformation.sServiceref) if sref: # strip all after last : pos = sref.rfind(':') if pos != -1: if sref[pos-1] == ':': pos -= 1 sref = sref[:pos+1] sref = ServiceReference(sref) if info: begin = info.getInfo(service, iServiceInformation.sTimeCreate) end = begin + info.getLength(service) else: begin = end = 0 from os.path import dirname path = dirname(service.getPath()) if not path == '/': path += '/' tags = info.getInfoString(service, iServiceInformation.sTags) tags = tags and tags.split(' ') or [] newTimer = autotimer.defaultTimer.clone() newTimer.id = autotimer.getUniqueId() newTimer.name = name newTimer.match = '' newTimer.enabled = True # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-) session.openWithCallback( importerCallback, AutoTimerImporter, newTimer, match, # Proposed Match begin, # Proposed Begin end, # Proposed End None, # Proposed Disabled sref, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay path, # Proposed dirname tags # Proposed tags )
def addAutotimerFromEvent(session, evt = None, service = None): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer # Create instance if needed if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() else: autotimer.readXml() match = evt and evt.getEventName() or "" name = match or "New AutoTimer" sref = None if service is not None: service = str(service) myref = eServiceReference(service) if not (myref.flags & eServiceReference.isGroup): # strip all after last : pos = service.rfind(':') if pos != -1: if service[pos-1] == ':': pos -= 1 service = service[:pos+1] sref = ServiceReference(myref) if evt: # timespan defaults to +- 1h begin = evt.getBeginTime()-3600 end = begin + evt.getDuration()+7200 else: begin = end = 0 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-) newTimer = autotimer.defaultTimer.clone() newTimer.id = autotimer.getUniqueId() newTimer.name = name newTimer.match = '' newTimer.enabled = True session.openWithCallback( importerCallback, AutoTimerImporter, newTimer, match, # Proposed Match begin, # Proposed Begin end, # Proposed End None, # Proposed Disabled sref, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay None, # Proposed dirname, can we get anything useful here? [] # Proposed tags )
def addAutotimerFromEvent(session, evt = None, service = None): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer # Create instance if needed if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() match = evt and evt.getEventName() or "" name = match or "New AutoTimer" sref = None if service is not None: service = str(service) myref = eServiceReference(service) if not (myref.flags & eServiceReference.isGroup): # strip all after last : pos = service.rfind(':') if pos != -1: if service[pos-1] == ':': pos -= 1 service = service[:pos+1] sref = ServiceReference(myref) if evt: # timespan defaults to +- 1h begin = evt.getBeginTime()-3600 end = begin + evt.getDuration()+7200 else: begin = end = 0 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-) newTimer = autotimer.defaultTimer.clone() newTimer.id = autotimer.getUniqueId() newTimer.name = name newTimer.match = '' newTimer.enabled = True session.openWithCallback( importerCallback, AutoTimerImporter, newTimer, match, # Proposed Match begin, # Proposed Begin end, # Proposed End None, # Proposed Disabled sref, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay None, # Proposed dirname, can we get anything useful here? [] # Proposed tags )
def render_POST(self, req): req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml;') req.setHeader('charset', 'UTF-8') autotimer.readXml( ) # read current timers to ensure autotimer.timers is populated with current autotimers autotimer.readXmlTimer(req.args['xml'][0]) if config.plugins.autotimer.always_write_config.value: autotimer.writeXml() return self.returnResult(req, True, _("AutoTimer was added successfully"))
def render(self, req): # We re-read the config so we won't display empty or wrong information try: autotimer.readXml() except Exception: return self.returnResult(req, False, _("Couldn't load config file!")) # show xml req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml') req.setHeader('charset', 'UTF-8') return ''.join(autotimer.getXml())
def render(self, req): # We re-read the config so we won't display empty or wrong information try: autotimer.readXml() except Exception as e: return self.returnResult(req, False, _("Couldn't load config file!") + '\n' + str(e)) # show xml req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml') req.setHeader('charset', 'UTF-8') return ''.join(autotimer.getXml())
def render(self, req): req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml;') req.setHeader('charset', 'UTF-8') xml = req.args.get("xml") if xml: autotimer.readXml(xml_string=xml[0]) if config.plugins.autotimer.always_write_config.value: autotimer.writeXml() return self.returnResult(req, True, _("AutoTimers were changed successfully")) else: return self.returnResult(req, False, _("Not found xml config file!"))
def render(self, req): # We re-read the config so we won't display empty or wrong information try: autotimer.readXml() except Exception as e: return self.returnResult(req, False, _("Couldn't load config file!") + "\n" + str(e)) # show xml req.setResponseCode(http.OK) req.setHeader("Content-type", "application/xhtml+xml") req.setHeader("charset", "UTF-8") return "".join(autotimer.getXml())
def editorCallback(ret): if ret: from plugin import autotimer autotimer.readXml() autotimer.add(ret) # Save modified xml autotimer.writeXml() autotimer.readXml() autotimer.parseEPG()
def editorCallback(ret): if ret: from plugin import autotimer if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() autotimer.add(ret) # Save modified xml autotimer.writeXml()
def addAutotimerFromEventSilent(session, evt = None, service = None): from plugin import autotimer autotimer.readXml() match = evt and evt.getEventName() or "" name = match or "New AutoTimer" if service is not None: service = str(service) myref = eServiceReference(service) if not (myref.flags & eServiceReference.isGroup): # strip all after last : pos = service.rfind(':') if pos != -1: if service[pos-1] == ':': pos -= 1 service = service[:pos+1] if evt: # timespan defaults to +- 1h begin = evt.getBeginTime()-3600 end = begin + evt.getDuration()+7200 else: begin = end = 0 begin = localtime(begin) end = localtime(end) newTimer = autotimer.defaultTimer.clone() newTimer.id = autotimer.getUniqueId() newTimer.name = name newTimer.match = name if newTimer.timespan[0]: newTimer.timespan = ((begin[3], begin[4]), (end[3], end[4]),False) if newTimer.include: includes = [ newTimer.getIncludedTitle(), newTimer.getIncludedShort(), newTimer.getIncludedDescription(), [str(begin.tm_wday)], ] newTimer.include = includes newTimer.services = [service] newTimer.enabled = True AutoTimerEditorSilentDialog = session.instantiateDialog(AutoTimerEditorSilent, newTimer) retval = AutoTimerEditorSilentDialog.retval() session.deleteDialogWithCallback(editorCallback, AutoTimerEditorSilentDialog, retval)
def render(self, req): # We re-read the config so we won't display empty or wrong information try: autotimer.readXml() except Exception as e: return self.returnResult(req, False, _("Couldn't load config file!") + '\n' + str(e)) webif = True p = req.args.get('webif') if p: webif = not(p[0] == "false") # show xml req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml') req.setHeader('charset', 'UTF-8') return ''.join(autotimer.getXml(webif))
def render(self, req): req.setResponseCode(http.OK) req.setHeader('Content-type', 'application/xhtml+xml;') req.setHeader('charset', 'UTF-8') xml = req.args.get("xml") if xml: autotimer.readXml( ) # read current timers to ensure autotimer.timers is populated with current autotimers autotimer.readXmlTimer(xml[0]) if config.plugins.autotimer.always_write_config.value: autotimer.writeXml() return self.returnResult(req, True, _("AutoTimer was added successfully")) else: return self.returnResult(req, False, _("missing parameter \"xml\""))
def editorCallback(ret): if ret: from plugin import autotimer # Create instance if needed (should have been created by addAutotimerFrom* above though) if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() autotimer.add(ret) # Save modified xml autotimer.writeXml() # Remove instance if not running in background if not config.plugins.autotimer.autopoll.value: autotimer = None