def test(session=None): # http://dm7080/autotimer # http://www.unixtime.de/ try: #from SeriesPluginBare import bareGetEpisode #future=True, today=False, elapsed=False #bareGetEpisode("1:0:19:7C:6:85:FFFF0000:0:0:0:", "The Walking Dead", 1448740500, 1448745600, "Description", "/media/hdd/movie", True, False, False) #bareGetEpisode("1:0:1:2F50:F1:270F:FFFF0000:0:0:0:", "Are You the One?", 1448923500, 1448926500, "Description", "/media/hdd/movie", False, False, True) #bareGetEpisode("1:0:19:814D:14B:270F:FFFF0000:0:0:0:", "Bones", 1451416200, 1451416200, "Description", "/media/hdd/movie", False, True, False) #sp = bareGetEpisode("1:0:19:2B66:437:66:FFFF0000:0:0:0:", "Bares für Rares", 1451311500, 1451311500, "Description", "/media/hdd/movie", False, True, False) #sp = bareGetEpisode("1:0:19:7980:1C3:270F:FFFF0000:0:0:0:", "Offroad Survivors", 1451492100, 1451492100, "Description", "/media/hdd/movie", False, True, False) #from Tools.Notifications import AddPopup #from Screens.MessageBox import MessageBox #AddPopup( sp[0], MessageBox.TYPE_INFO, 0, 'SP_PopUp_ID_Test' ) #TEST INFOSCREEN MOVIE # from enigma import eServiceReference #service = eServiceReference(eServiceReference.idDVB, 0, "/media/hdd/movie/20151120 0139 - Pro7 HD - The 100.ts") #service = eServiceReference(eServiceReference.idDVB, 0, "/media/hdd/movie/20151205 1625 - TNT Serie HD (S) - The Last Ship - Staffel 1.ts") #service = eServiceReference(eServiceReference.idDVB, 0, "/media/hdd/movie/20151204 1825 - VIVA_COMEDY CENTRAL HD - Rules of Engagement.ts") # movielist_info(session, service) #TEST AUTOTIMER #from SeriesPluginBare import bareGetEpisode #bareGetEpisode("1:0:1:2F50:F1:270F:FFFF0000:0:0:0:", "Are You the One", 1448751000, 1448754000, "Description", "/media/hdd/movie", False, False, True) #bareGetEpisode("1:0:19:8150:14B:270F:FFFF0000:0:0:0:", "Dragons Auf zu neuen Ufern TEST_TO_BE_REMOVED", 1449390300, 1449393300, "Description", "/media/hdd/movie", False, False, True) pass except Exception as e: log.exception(_("SeriesPlugin test exception ") + str(e))
def refactorDirectory(org, data): dir = org if data: if ( config.plugins.seriesplugin.pattern_directory.value and not config.plugins.seriesplugin.pattern_directory.value == "Off" and not config.plugins.seriesplugin.pattern_directory.value == "Disabled" ): data["org"] = org cust_ = config.plugins.seriesplugin.pattern_directory.value.strip().format(**data) cust_ = ( cust_.replace("\n", "") .replace("&", "&") .replace("'", "'") .replace(">", ">") .replace("<", "<") .replace(""", '"') .replace(" ", " ") .replace("//", "/") ) dir = CompiledRegexpReplaceDirChars.sub(" ", cust_) log.debug(" refactor dir", org, cust_, dir) if dir and not os.path.exists(dir): try: os.makedirs(dir) except: log.exception("makedirs exception", dir) return dir
def getSeasonEpisode( self, name, webChannel, unixtime, max_time_drift ): result = None skipped = self.skip.get(name, None) if skipped: if ( time() - skipped ) < skip_expiration: #return _("Skipped") socket.setdefaulttimeout( reduced_timeout ) else: del self.skip[name] try: result = self.sp.cache.getSeasonEpisode( name, webChannel, unixtime, max_time_drift ) log.debug("SerienServer getSeasonEpisode result:", result) except Exception as e: msg = "Exception in xmlrpc: \n" + str(e) + ' - ' + str(result) + "\n\nfor" + name + " (" + webChannel + ")" if not config.plugins.seriesplugin.autotimer_independent.value: log.exception(msg) else: # The independant mode could have a lot of non series entries log.debug(msg) self.skip[name] = time() result = str(e) if skipped: timeout = config.plugins.seriesplugin.socket_timeout.value socket.setdefaulttimeout( float(timeout) ) return result
def loadModules(self, path, base): modules = {} if not os.path.exists(path): return # Import all subfolders to allow relative imports for root, dirs, files in os.walk(path): if root not in sys.path: sys.path.append(root) # Import PushService modules files = [fname[:-3] for fname in os.listdir(path) if fname.endswith(".py")] for name in files: module = None if name == "__init__": continue try: fp, pathname, description = imp.find_module(name, [path]) except Exception, e: log.exception( ("PushService Find module exception: ") + str(e) ) fp = None if not fp: log.debug( ("PushService No module found: ") + str(name) ) continue try: module = imp.load_module( name, fp, pathname, description) except Exception, e: log.exception( ("PushService Load exception: ") + str(e) )
def instantiateModule(self, module): if module and callable(module): # Create instance try: return module() except Exception, e: log.exception( ("PushService Instantiate exception: ") + str(module) + "\n" + str(e) )
def renameTimer(timer, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: try: spt = SeriesPluginTimer() spt.getEpisode(timer) except Exception as e: log.exception(_("SeriesPlugin label exception ") + str(e))
def show(session, **kwargs): log.info( "InfoBarTunerState show" ) if gInfoBarTunerState: try: gInfoBarTunerState.show(True, forceshow=True) except Exception, e: log.exception( "InfoBarTunerState show exception " + str(e) )
def readXML(self): path = self.__path log.debug("Read XML from " + str(path)) if not path: log.debug("No configuration file given") return None # Abort if no config found if not os.path.exists(path): log.debug("Configuration file does not exist") return None # Parse if mtime differs from whats saved mtime = os.path.getmtime(path) if mtime == self.__mtime: # No changes in configuration, won't read again return self.__cache # Parse XML try: etree = parse(path) except Exception as e: log.exception("Exception in read XML: " + str(e)) etree = None mtime = -1 # Save time and cache file content self.__mtime = mtime self.__cache = etree return self.__cache
def sp_extension(session, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: try: if session: session.open(SeriesPluginInfoScreen) except Exception as e: log.exception(_("SeriesPlugin extension exception ") + str(e))
def getWebChannels(self): result = None try: result = self.sp.cache.getWebChannels() except Exception as e: log.exception("Exception in xmlrpc: " + str(e) + ' - ' + str(result)) return result
def labelTimer(timer, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: log.debug("SeriesPlugin labelTimer is deprecated - Update Your AutoTimer!") try: spt = SeriesPluginTimer() spt.getEpisode(timer) except Exception as e: log.exception(_("SeriesPlugin label exception ") + str(e))
def getSeasonEpisode4(service_ref, name, begin, end, description, path, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: from SeriesPluginBare import bareGetEpisode try: return bareGetEpisode(service_ref, name, begin, end, description, path, True, False, False) except Exception as e: log.exception( "SeriesPlugin getSeasonEpisode4 exception " + str(e)) return str(e)
def showTimerInfo(session, timer, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: from enigma import eEPGCache try: event = timer.eit and epgcache.lookupEventId(timer.service_ref.ref, timer.eit) session.open(SeriesPluginInfoScreen, timer.service_ref, event) except Exception as e: log.exception(_("SeriesPlugin info exception ") + str(e))
def autostart(reason, **kwargs): if reason == 0: # start if config.pushservice.enable.value: try: global gPushService gPushService = PushService() gPushService.start() except Exception, e: log.exception( ("PushService autostart exception ") + str(e) )
def channel(session, service=None, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: try: from enigma import eServiceCenter info = eServiceCenter.getInstance().info(service) event = info.getEvent(service) session.open(SeriesPluginInfoScreen, service, event) except Exception as e: log.exception(_("SeriesPlugin extension exception ") + str(e))
def setup(session, **kwargs): try: ### For testing only import ConfigScreen reload(ConfigScreen) ### session.open(ConfigScreen.ConfigScreen) except Exception, e: log.exception( ("PushService setup exception ") + str(e) )
def getSeasonAndEpisode(timer, *args, **kwargs): result = None if config.plugins.seriesplugin.enabled.value: log.debug("SeriesPlugin getSeasonAndEpisode is deprecated - Update Your AutoTimer!") try: spt = SeriesPluginTimer() result = spt.getEpisode(timer, True) except Exception as e: log.exception(_("SeriesPlugin label exception ") + str(e)) return result
def movielist_rename(session, service, services=None, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: try: if services: if not isinstance(services, list): services = [services] else: services = [service] SeriesPluginRenamer(session, services) except Exception as e: log.exception(_("SeriesPlugin renamer exception ") + str(e))
def start(reason, **kwargs): log.info( "InfoBarTunerState start" ) if reason == 0: # start if kwargs.has_key("session"): if config.infobartunerstate.enabled.value: global gInfoBarTunerState session = kwargs["session"] try: gInfoBarTunerState = InfoBarTunerState(session) gInfoBarTunerState.onInit() except Exception, e: log.exception( "InfoBarTunerState start exception " + str(e) )
def getSeasonEpisode(service_ref, name, begin, end, description, path, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: log.debug("SeriesPlugin getSeasonEpisode is deprecated - Update Your AutoTimer!") from SeriesPluginBare import bareGetEpisode try: result = bareGetEpisode(service_ref, name, begin, end, description, path) if result and isinstance(result, dict): return (result[0],result[1],result[2]) else: return str(result) except Exception as e: log.exception( "SeriesPlugin getSeasonEpisode4 exception " + str(e)) return str(e)
def writeXML(self, etree): path = config.pushservice.xmlpath.value indent(etree) data = tostring(etree, 'utf-8') f = None try: f = open(path, 'w') if data: f.writelines(data) except Exception, e: log.exception( ("PushService Exception in writeXML: ") + str(e) )
def instantiateModule(self, module): if module and callable(module): # Create instance try: return module() except Exception as e: log.exception("[SeriesService] Instantiate exception: " + str(module) + "\n" + str(e)) if sys.exc_info()[0]: log.debug("Unexpected error: ", sys.exc_info()[0]) traceback.print_exc(file=sys.stdout) return None else: log.debug("[SeriesService] Module is not callable: " + str(module.getClass())) return None
def loadXML(self): try: # Read xml config file etree = self.readXML() if etree: channels = {} # Parse Config def parse(root): channels = {} version = root.get("version", "1") if version.startswith("1"): log.warning( _("Skipping old channels file") ) elif version.startswith("2") or version.startswith("3") or version.startswith("4"): log.debug("Channel XML Version 4") ChannelsBase.channels_changed = True if root: for element in root.findall("Channel"): name = element.get("name", "") reference = element.get("reference", "") if name and reference: alternatives = [] for alternative in element.findall("Alternative"): alternatives.append( alternative.text ) channels[reference] = (name, list(set(alternatives))) log.debug("Channel", reference, channels[reference] ) else: # XMLTV compatible channels file log.debug("Channel XML Version 5") if root: for element in root.findall("channel"): alternatives = [] id = readFromXML(element.get("id", "")) alternatives.append( id ) name = readFromXML(element.get("name", "")) reference = readFromXML(element.text) #Test customization but XML conform for web in element.findall("web"): alternatives.append( readFromXML(web.text) ) channels[reference] = (name, list(set(alternatives))) log.debug("Channel", reference, channels[reference] ) return channels channels = parse( etree.getroot() ) log.debug("Channel XML load", len(channels)) else: channels = {} ChannelsBase.channels = channels except Exception as e: log.exception("Exception in loadXML: " + str(e))
def writeXML(self, etree): path = self.__path log.debug("Write XML to " + path) try: etree.write(path, encoding='utf-8', xml_declaration=True) except Exception as e: log.exception("Exception in write XML: " + str(e)) etree = None mtime = -1 # Save time and cache file content self.__mtime = os.path.getmtime( path ) self.__cache = etree
def runIndependent(): try: spt = SeriesPluginTimer() for timer in NavigationInstance.instance.RecordTimer.timer_list: #Maybe later # Add a series whitelist # Configured with a dialog # Stored in a db or xml spt.getEpisode(timer) except Exception as e: log.exception( _("Independent mode exception") + "\n" + str(e))
def refactorDirectory(org, data): dir = org if data: if config.plugins.seriesplugin.pattern_directory.value and not config.plugins.seriesplugin.pattern_directory.value == "Off" and not config.plugins.seriesplugin.pattern_directory.value == "Disabled": data["org"] = org data["home"] = "/media/hdd/movie" cust_ = config.plugins.seriesplugin.pattern_directory.value.strip().format( **data ) cust_ = cust_.replace("\n", "").replace('&','&').replace(''',"'").replace('>','>').replace('<','<').replace('"','"').replace(" ", " ").replace("//", "/") dir = CompiledRegexpReplaceDirChars.sub(' ', cust_) log.debug(" refactor dir", org, cust_, dir) if dir and not os.path.exists(dir): try: os.makedirs(dir) except: log.exception("makedirs exception", dir) return dir
def setup(session, **kwargs): log.info( "InfoBarTunerState setup" ) #TODO config # Overwrite Skin Position # Show Live TV Tuners PiP LiveStream FileStream # alltime permanent display, needs an dynamic update service # Always display at least Nothing running # show free tuner with dvb-type # Used disk size # Event popup timeout # Feldbreitenbegrenzung fuer Namen ... # Streaming amount of data # Display next x timers also if deactivated try: session.open(InfoBarTunerStateConfiguration) except Exception, e: log.exception( "InfoBarTunerStateMenu exception " + str(e) )
def readDirectoryPatterns(): path = config.plugins.seriesplugin.pattern_file_directories.value obj = None patterns = None if os.path.exists(path): log.debug("Found directory pattern file") f = None try: f = open(path, 'rb') header, patterns = json.load(f) patterns = [tuple(p) for p in patterns] except Exception as e: log.exception(_("Your pattern file is corrupt") + "\n" + path + "\n\n" + str(e)) finally: if f is not None: f.close() return patterns or scheme_fallback
def __init__(self, session, test): Screen.__init__(self, session) self.skinName = ["TestBox", "Console"] title = "" text = "" self.test = test self["text"] = ScrollLabel("") self["actions"] = ActionMap(["WizardActions", "DirectionActions"], { "ok": self.cancel, "back": self.cancel, "up": self["text"].pageUp, "down": self["text"].pageDown }, -1) # Set title and text test.begin() if isinstance(test, ServiceBase): title = _("Testing Service") + " " + test.getName() text = _("Testing...\n\nCancel?") elif isinstance(test, ControllerBase): title = _("Testing Controller") + " " + test.getName() text = _("Testing...\n\nCancel?") else: title = _("Testing") text = _("Nothing to test") self.setTitle(title) self.setText(text) # Starting test try: if isinstance(test, ServiceBase): test.push( self.callback, self.errback, _("PushService Config"), _("Push test"), _("If You can see this, Your configuration is correct.") ) elif isinstance(test, ControllerBase): test.run( self.callback, self.errback ) except Exception, e: text = _("PushService Test exception:") + str(e) + "\n\n" exc_type, exc_value, exc_traceback = sys.exc_info() for line in traceback.format_exception(exc_type, exc_value, exc_traceback): text += line log.exception( text ) self.setText(text)
def osrename(src, dst): #Py3 for f in glob( escape(src) + "*" ): glob_src = CompiledRegexpGlobEscape.sub("[\\1]", src) log.debug("glob_src ", glob_src) for f in glob( glob_src + ".*" ): log.debug("servicepathRnm", f) to = f.replace(src, dst) log.debug("servicepathTo ", to) if not os.path.exists(to): try: os.rename(f, to) except: log.exception("rename error", f, to) elif config.plugins.seriesplugin.rename_existing_files.value: log.debug("Destination file already exists", to, " - Append '_'") return osrename( src, dst + "_") break else: log.warning( _("Skipping rename because file already exists") + "\n" + to + "\n\n" + _("Can be configured within the setup") ) return True
def writeXMLTVConfig(self): if self.epgimport is None and self.xmltvimport is None and self.crossepg is None: return if int(self.epgimportversion[0]) >= 5 and int( self.xmltvimportversion[0]) >= 5 and int( self.crossepgversion[0]) >= 5: return if config.plugins.seriesplugin.epgimport.value == False and config.plugins.seriesplugin.xmltvimport.value == False and config.plugins.seriesplugin.crossepg.value == False: return # Build Header from plugin import NAME, VERSION root = Element("sources") root.set('version', VERSION) root.set('created_by', NAME) root.append( Comment( _("Don't edit this manually unless you really know what you are doing" ))) element = SubElement(root, "source", type="gen_xmltv", channels="wunschliste.channels.xml") SubElement(element, "description").text = "Wunschliste XMLTV" SubElement(element, "url").text = config.plugins.seriesplugin.xmltv_url.value etree = ElementTree(root) indent(etree.getroot()) if config.plugins.seriesplugin.epgimport.value: log.debug("Write: xml channels for epgimport") if self.epgimport: try: self.epgimport.writeXML(etree) except Exception as e: log.exception("Exception in write XML: " + str(e)) if config.plugins.seriesplugin.xmltvimport.value: log.debug("Write: xml channels for xmltvimport") if self.xmltvimport: try: self.xmltvimport.writeXML(etree) except Exception as e: log.exception("Exception in write XML: " + str(e)) if config.plugins.seriesplugin.crossepg.value: log.debug("Write: xml channels for crossepg") if self.crossepg: try: self.crossepg.writeXML(etree) except Exception as e: log.exception("Exception in write XML: " + str(e))
def osrename(src, dst): #Py3 for f in glob( escape(src) + "*" ): glob_src = CompiledRegexpGlobEscape.sub("[\\1]", src) log.debug("glob_src ", glob_src) for f in glob(glob_src + ".*"): log.debug("servicepathRnm", f) to = f.replace(src, dst) log.debug("servicepathTo ", to) if not os.path.exists(to): try: os.rename(f, to) except: log.exception("rename error", f, to) elif config.plugins.seriesplugin.rename_existing_files.value: log.debug("Destination file already exists", to, " - Append '_'") return osrename(src, dst + "_") break else: log.warning( _("Skipping rename because file already exists") + "\n" + to + "\n\n" + _("Can be configured within the setup")) return True
def rename(servicepath, name, short, data): # Episode data available log.debug("rename:", data) result = True #MAYBE Check if it is already renamed? try: # Before renaming change content rewriteMeta(servicepath, name, data) except Exception as e: log.exception("rewriteMeta:", str(e)) result = "rewriteMeta:" + str(e) if config.plugins.seriesplugin.pattern_title.value and not config.plugins.seriesplugin.pattern_title.value == "Off": if config.plugins.seriesplugin.rename_file.value == True: try: renameFiles(servicepath, name, data) except Exception as e: log.exception("renameFiles:", str(e)) result = "renameFiles:" + str(e) return result
def saveXML(self): try: if ChannelsBase.channels_changed: ChannelsBase.channels_changed = False channels = ChannelsBase.channels # Generate List in RAM etree = None #log.debug("saveXML channels", channels) log.debug("SP saveXML channels", len(channels)) # XMLTV compatible channels file #TEST Do we need to write the xml header node # Build Header from plugin import NAME, VERSION root = Element("channels") root.set('version', VERSION) root.set('created_by', NAME) root.append(Comment(_("Don't edit this manually unless you really know what you are doing"))) # Build Body def build(root, channels): if channels: for reference, namealternatives in channels.iteritems(): name, alternatives = namealternatives[:] if alternatives: # Add channel web = alternatives[0] element = SubElement( root, "channel", name = stringToXML(name), id = stringToXML(web) ) element.text = stringToXML(reference) del alternatives[0] if alternatives: for web in alternatives: SubElement( element, "web" ).text = stringToXML(web) return root etree = ElementTree( build( root, channels ) ) indent(etree.getroot()) self.writeXML( etree ) if config.plugins.seriesplugin.epgimport.value: log.debug("Write: xml channels for epgimport") try: path = "/etc/epgimport/wunschliste.channels.xml" etree.write(path, encoding='utf-8', xml_declaration=True) except Exception as e: log.exception("Exception in write XML: " + str(e)) if config.plugins.seriesplugin.xmltvimport.value: log.debug("Write: xml channels for xmltvimport") try: path = "/etc/xmltvimport/wunschliste.channels.xml" etree.write(path, encoding='utf-8', xml_declaration=True) except Exception as e: log.exception("Exception in write XML: " + str(e)) if config.plugins.seriesplugin.crossepg.value: log.debug("Write: xml channels for crossepg") try: path = "/etc/crossepg/wunschliste.channels.xml" etree.write(path, encoding='utf-8', xml_declaration=True) except Exception as e: log.exception("Exception in write XML: " + str(e)) except Exception as e: log.exception("Exception in writeXML: " + str(e))
def confirm(self, confirmed): if confirmed and self.services: serviceHandler = eServiceCenter.getInstance() try: for service in self.services: seriesPlugin = getInstance() if isinstance(service, eServiceReference): service = service elif isinstance(service, ServiceReference): service = service.ref else: log.debug("Wrong instance") continue servicepath = service.getPath() if not os.path.exists(servicepath): log.debug("File not exists: " + servicepath) continue info = serviceHandler.info(service) if not info: log.debug("No info available: " + servicepath) continue short = "" begin = None end = None duration = 0 event = info.getEvent(service) if event: name = event.getEventName() or "" short = event.getShortDescription() begin = event.getBeginTime() duration = event.getDuration() or 0 end = begin + duration or 0 # We got the exact start times, no need for margin handling log.debug("event") else: name = service.getName() or info.getName(service) or "" if name[-2:] == 'ts': name = name[:-2] log.debug("not event") if not begin: begin = info.getInfo( service, iServiceInformation.sTimeCreate) or -1 if begin != -1: end = begin + (info.getLength(service) or 0) else: end = os.path.getmtime(servicepath) begin = end - (info.getLength(service) or 0) #MAYBE we could also try to parse the filename log.debug( "We don't know the exact margins, we will assume the E2 default margins" ) begin -= (int(config.recording.margin_before.value) * 60) end += (int(config.recording.margin_after.value) * 60) rec_ref_str = info.getInfoString( service, iServiceInformation.sServiceref) #channel = ServiceReference(rec_ref_str).getServiceName() log.debug("getEpisode:", name, begin, end, rec_ref_str) seriesPlugin.getEpisode(boundFunction( self.renamerCallback, servicepath, name, short), name, begin, end, rec_ref_str, elapsed=True, block=True, rename=True) except Exception as e: log.exception("Exception:", str(e))
def getInstance(): global instance if instance is None: log.reinit() from plugin import VERSION log.debug(" SERIESPLUGIN NEW INSTANCE " + VERSION) log.debug( " ", strftime("%a, %d %b %Y %H:%M:%S", localtime()) ) try: from Tools.HardwareInfo import HardwareInfo log.debug( " DeviceName " + HardwareInfo().get_device_name().strip() ) except: sys.exc_clear() try: from Components.About import about log.debug( " EnigmaVersion " + about.getEnigmaVersionString().strip() ) log.debug( " ImageVersion " + about.getVersionString().strip() ) except: sys.exc_clear() try: #http://stackoverflow.com/questions/1904394/python-selecting-to-read-the-first-line-only log.debug( " dreamboxmodel " + open("/proc/stb/info/model").readline().strip() ) log.debug( " imageversion " + open("/etc/image-version").readline().strip() ) log.debug( " imageissue " + open("/etc/issue.net").readline().strip() ) except: sys.exc_clear() try: for key, value in config.plugins.seriesplugin.dict().iteritems(): log.debug( " config..%s = %s" % (key, str(value.value)) ) except Exception as e: sys.exc_clear() global CompiledRegexpReplaceChars try: if config.plugins.seriesplugin.replace_chars.value: CompiledRegexpReplaceChars = re.compile('['+config.plugins.seriesplugin.replace_chars.value.replace("\\", "\\\\\\\\")+']') except: log.exception( " Config option 'Replace Chars' is no valid regular expression" ) CompiledRegexpReplaceChars = re.compile("[:\!/\\,\(\)'\?]") # Check autotimer try: from Plugins.Extensions.AutoTimer.plugin import autotimer deprecated = False try: from Plugins.Extensions.AutoTimer.plugin import AUTOTIMER_VERSION if int(AUTOTIMER_VERSION[0]) < 4: deprecated = True except ImportError: AUTOTIMER_VERSION = "deprecated" deprecated = True log.debug( " AutoTimer: " + AUTOTIMER_VERSION ) if deprecated: log.warning( _("Your autotimer is deprecated") + "\n" +_("Please update it") ) except ImportError: log.debug( " AutoTimer: Not found" ) # Check dependencies start = True from imp import find_module dependencies = ["difflib", "json", "re", "xml", "xmlrpclib"] for dependency in dependencies: try: find_module(dependency) except ImportError: start = False log.error( _("Error missing dependency") + "\n" + "python-"+dependency + "\n\n" +_("Please install missing python paket manually") ) if start: instance = SeriesPlugin() return instance
def getEpisode(self, callback, name, begin, end=None, service=None, future=False, today=False, elapsed=False, block=False, rename=False): if config.plugins.seriesplugin.skip_during_records.value: try: import NavigationInstance if NavigationInstance.instance.RecordTimer.isRecording(): msg = _("Skip check during running records") + "\n\n" + _("Can be configured within the setup") log.warning( msg) if callable(callback): callback(msg) return msg except: pass # Check for episode information in title match = self.compiledRegexpSeries.match(name) if match: #log.debug(match.group(0)) # Entire match #log.debug(match.group(1)) # First parenthesized subgroup if not rename and config.plugins.seriesplugin.skip_pattern_match.value: msg = _("Skip check because of pattern match") + "\n" + name + "\n\n" + _("Can be configured within the setup") log.warning(msg) if callable(callback): callback(msg) return msg if match.group(1): name = match.group(1) if elapsed: identifier = self.identifier_elapsed elif today: identifier = self.identifier_today elif future: identifier = self.identifier_future else: identifier = self.modules and self.instantiateModule( self.modules.itervalues().next() ) if not identifier: msg = _("No identifier available") + "\n\n" + _("Please check Your installation") log.error(msg) if callable(callback): callback(msg) return msg elif self.channelsEmpty(): msg = _("Channels are not matched") + "\n\n" + _("Please open the channel editor (setup) and match them") log.error(msg) if callable(callback): callback(msg) return msg else: # Reset title search depth on every new request identifier.search_depth = 0; # Reset the knownids on every new request identifier.knownids = [] try: serviceref = service.toString() except: sys.exc_clear() serviceref = str(service) serviceref = re.sub('::.*', ':', serviceref) if block == False: self.thread.add( ThreadItem(identifier, callback, name, begin, end, serviceref) ) else: result = None try: result = identifier.getEpisode( name, begin, end, serviceref ) except Exception, e: log.exception("Worker:", str(e)) # Exception finish job with error result = str(e) config.plugins.seriesplugin.lookup_counter.value += 1 data = normalizeResult(result) if callable(callback): callback(data) return data
def getEpisode(self): self.name = "" self.short = "" self.data = None begin, end, duration = 0, 0, 0 ext, channel = "", "" future = True today = False elapsed = False if self.service: service = self.service else: service = self.service = self.session and self.session.nav.getCurrentlyPlayingServiceReference() ref = None if isinstance(service, eServiceReference): #ref = service #Problem EPG self.eservice = service self.path = service.getPath() if self.path: # Service is a movie reference info = self.serviceHandler.info(service) ref = info.getInfoString(service, iServiceInformation.sServiceref) sref = ServiceReference(ref) ref = sref.ref channel = sref.getServiceName() if not channel: ref = str(ref) ref = re.sub('::.*', ':', ref) sref = ServiceReference(ref) ref = sref.ref channel = sref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '') # Get information from record meta files self.event = info and info.getEvent(service) future = False today = False elapsed = True log.debug("eServiceReference movie", str(ref)) else: # Service is channel reference ref = service channel = ServiceReference(str(service)).getServiceName() or "" if not channel: try: channel = ServiceReference(service.toString()).getServiceName() or "" except: pass # Get information from event log.debug("eServiceReference channel", str(ref)) elif isinstance(service, ServiceReference): ref = service.ref channel = service.getServiceName() log.debug("ServiceReference", str(ref)) elif isinstance(service, ChannelSelectionBase): ref = service.getCurrentSelection() channel = ServiceReference(ref).getServiceName() or "" log.debug("ChannelSelectionBase", str(ref)) # Fallbacks if ref is None: ref = self.session and self.session.nav.getCurrentlyPlayingServiceReference() channel = getChannel(ref) log.debug("Fallback ref", ref, str(ref), channel) if not isinstance(self.event, eServiceEvent): try: self.event = ref.valid() and self.epg.lookupEventTime(ref, -1) except: # Maybe it is an old reference # Has the movie been renamed earlier? # Refresh / reload the list? self["event_episode"].setText( "No valid selection!" ) log.debug("No valid selection", str(ref)) return # Get information from epg future = False today = True elapsed = False log.debug("Fallback event", self.event) self.service = ref if self.event: self.name = self.event.getEventName() or "" begin = self.event.getBeginTime() or 0 duration = self.event.getDuration() or 0 end = begin + duration or 0 # We got the exact margins, no need to adapt it self.short = self.event.getShortDescription() or "" ext = self.event.getExtendedDescription() or "" log.debug("event") if not begin: info = self.serviceHandler.info(eServiceReference(str(ref))) #log.debug("info") if info: #log.debug("if info") begin = info.getInfo(ref, iServiceInformation.sTimeCreate) or 0 if begin: duration = info.getLength(ref) or 0 end = begin + duration or 0 log.debug("sTimeCreate") else: end = os.path.getmtime(ref.getPath()) or 0 duration = info.getLength(ref) or 0 begin = end - duration or 0 log.debug("sTimeCreate else") elif ref: path = ref.getPath() #log.debug("getPath") if path and os.path.exists(path): begin = os.path.getmtime(path) or 0 log.debug("getmtime") # We don't know the exact margins, we will assume the E2 default margins log.debug("We don't know the exact margins, we will assume the E2 default margins") begin = begin + (config.recording.margin_before.value * 60) end = end - (config.recording.margin_after.value * 60) if self.session: self.updateScreen(self.name, _("Retrieving Season, Episode and Title..."), self.short, ext, begin, duration, channel) logo = self.seriesPlugin.getLogo(future, today, elapsed) if logo: logopath = os.path.join(PIXMAP_PATH, logo+".png") if self.session and os.path.exists(logopath): self.loadPixmap("logo", logopath ) try: log.debug("getEpisode:", self.name, begin, end, ref) self.seriesPlugin.getEpisode( self.episodeCallback, self.name, begin, end, ref, future=future, today=today, elapsed=elapsed, block=False ) except Exception as e: log.exception("exception:", str(e)) self.episodeCallback(str(e))
def movielist_info(session, service, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: try: session.open(SeriesPluginInfoScreen, service) except Exception as e: log.exception(_("SeriesPlugin extension exception ") + str(e))
def info(session, service=None, event=None, *args, **kwargs): if config.plugins.seriesplugin.enabled.value: try: session.open(SeriesPluginInfoScreen, service, event) except Exception as e: log.exception(_("SeriesPlugin info exception ") + str(e))
def setup(session, *args, **kwargs): try: session.open(SeriesPluginConfiguration) except Exception as e: log.exception(_("SeriesPlugin setup exception ") + str(e))