yet another fix
[vuplus_dvbapp-plugin] / epgsearch / src / plugin.py
index e597040..584ca14 100644 (file)
@@ -1,3 +1,8 @@
+# for localized messages        
+from . import _
+
+from enigma import eServiceCenter
+
 # Config
 from Components.config import config, ConfigSet, ConfigSubsection, ConfigText
 
@@ -7,26 +12,62 @@ config.plugins.epgsearch.history = ConfigSet(choices = [])
 config.plugins.epgsearch.encoding = ConfigText(default = 'ISO8859-15', fixed_size = False)
 
 # Plugin
-from EPGSearch import EPGSearch
+from EPGSearch import EPGSearch, EPGSearchEPGSelection, EPGSelectionInit
 
 # Plugin definition
 from Plugins.Plugin import PluginDescriptor
 
+# Autostart
+def autostart(reason, **kwargs):
+       if "session" in kwargs:
+               try:
+                       # for blue key activating in EPGSelection
+                       EPGSelectionInit()
+               except:
+                       pass
+
 # Mainfunction
 def main(session, *args, **kwargs):
-       session.open(EPGSearch)
+       s = session.nav.getCurrentService()
+       info = s.info()
+       event = info.getEvent(0) # 0 = now, 1 = next
+       name = event and event.getEventName() or ''
+       session.open(EPGSearch, name, False)
+
+# Event Info
+def eventinfo(session, *args, **kwargs):
+       ref = session.nav.getCurrentlyPlayingServiceReference()
+       session.open(EPGSearchEPGSelection, ref, True)
+
+# Movielist
+def movielist(session, service, **kwargs):
+       serviceHandler = eServiceCenter.getInstance()
+       info = serviceHandler.info(service)
+       name = info and info.getName(service) or ''
+
+       session.open(EPGSearch, name)
 
 def Plugins(**kwargs):
        return [
                PluginDescriptor(
+                       where = PluginDescriptor.WHERE_SESSIONSTART,
+                       fnc = autostart,
+               ),
+               PluginDescriptor(
                        name = "EPGSearch",
                        description = _("Search EPG"),
                        where = PluginDescriptor.WHERE_PLUGINMENU,
                        fnc = main,
                ),
                PluginDescriptor(
-                       name = _("Search EPG"),
+                       name = _("Search EPG..."),
                        where = PluginDescriptor.WHERE_EVENTINFO,
-                       fnc = main,
+                       fnc = eventinfo,
+               ),
+               PluginDescriptor(
+                       name = "EPGSearch",
+                       description = _("Search EPG..."),
+                       where = PluginDescriptor.WHERE_MOVIELIST,
+                       fnc = movielist,
                ),
        ]