imdb/ofdb: allow to select different event than the current one in eventinfo hook
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Fri, 16 Jan 2009 13:04:04 +0000 (13:04 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Fri, 16 Jan 2009 13:04:04 +0000 (13:04 +0000)
imdb/src/plugin.py
ofdb/src/plugin.py

index c054f53..0550c17 100755 (executable)
@@ -3,6 +3,7 @@ from Plugins.Plugin import PluginDescriptor
 from twisted.web.client import downloadPage
 from enigma import ePicLoad
 from Screens.Screen import Screen
+from Screens.EpgSelection import EPGSelection
 from Components.ActionMap import ActionMap
 from Components.Pixmap import Pixmap
 from Components.Label import Label
@@ -17,6 +18,30 @@ import re
 import htmlentitydefs
 import urllib
 
+class IMDBEPGSelection(EPGSelection):
+       def __init__(self, *args):
+               EPGSelection.__init__(self, *args)
+               self.skinName = "EPGSelection"
+               self["key_green"].setText(_("Lookup"))
+
+       def infoKeyPressed(self):
+               self.timerAdd()
+
+       def timerAdd(self):
+               cur = self["list"].getCurrent()
+               evt = cur[0]
+               sref = cur[1]
+               if not evt: 
+                       return
+
+               self.session.open(
+                       IMDB,
+                       evt.getEventName()
+               )
+
+       def onSelectionChanged(self):
+               pass
+
 class IMDB(Screen):
        skin = """
                <screen name="IMDB" position="90,95" size="560,420" title="Internet Movie Database Details Plugin" >
@@ -441,21 +466,29 @@ class IMDbLCDScreen(Screen):
                Screen.__init__(self, session)
                self["headline"] = Label("IMDB Plugin")
 
+def eventinfo(session, servicelist, **kwargs):
+       ref = session.nav.getCurrentlyPlayingServiceReference()
+       session.open(IMDBEPGSelection, ref)
+
 def main(session, eventName="", **kwargs):
        session.open(IMDB, eventName)
 
 def Plugins(**kwargs):
        try:
-               wherelist = [PluginDescriptor.WHERE_EVENTINFO, PluginDescriptor.WHERE_PLUGINMENU]
-               return PluginDescriptor(name="IMDb Details",
+               return [PluginDescriptor(name="IMDb Details",
                                description=_("Query details from the Internet Movie Database"),
                                icon="imdb.png",
-                               where = wherelist,
-                               fnc=main)
+                               where = PluginDescriptor.WHERE_PLUGINMENU,
+                               fnc = main),
+                               PluginDescriptor(name="IMDb Details",
+                               description=_("Query details from the Internet Movie Database"),
+                               where = PluginDescriptor.WHERE_EVENTINFO,
+                               fnc = eventinfo)
+                               ]
        except AttributeError:
                wherelist = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]
                return PluginDescriptor(name="IMDb Details",
                                description=_("Query details from the Internet Movie Database"),
                                icon="imdb.png",
                                where = wherelist,
-                               fnc=main)       
\ No newline at end of file
+                               fnc=main)       
index d94985c..f29fe4a 100644 (file)
@@ -3,6 +3,7 @@ from Plugins.Plugin import PluginDescriptor
 from twisted.web.client import downloadPage
 from enigma import ePicLoad
 from Screens.Screen import Screen
+from Screens.EpgSelection import EPGSelection
 from Components.ActionMap import ActionMap
 from Components.Pixmap import Pixmap
 from Components.Label import Label
@@ -17,6 +18,30 @@ import re
 import htmlentitydefs
 import urllib
 
+class OFDBEPGSelection(EPGSelection):
+       def __init__(self, *args):
+               EPGSelection.__init__(self, *args)
+               self.skinName = "EPGSelection"
+               self["key_green"].setText(_("Lookup"))
+
+       def infoKeyPressed(self):
+               self.timerAdd()
+
+       def timerAdd(self):
+               cur = self["list"].getCurrent()
+               evt = cur[0]
+               sref = cur[1]
+               if not evt: 
+                       return
+
+               self.session.open(
+                       OFDB,
+                       evt.getEventName()
+               )
+
+       def onSelectionChanged(self):
+               pass
+
 class OFDB(Screen):
        skin = """
                <screen name="OFDb" position="90,95" size="560,420" title="Internet Movie Database Details Plugin" >
@@ -407,17 +432,25 @@ class OFDbLCDScreen(Screen):
                Screen.__init__(self, session)
                self["headline"] = Label("OFDb Plugin")
 
+def eventinfo(session, servicelist, **kwargs):
+       ref = session.nav.getCurrentlyPlayingServiceReference()
+       session.open(OFDBEPGSelection, ref)
+
 def main(session, eventName="", **kwargs):
        session.open(OFDB, eventName)
        
 def Plugins(**kwargs):
        try:
-               wherelist = [PluginDescriptor.WHERE_EVENTINFO, PluginDescriptor.WHERE_PLUGINMENU]
-               return PluginDescriptor(name="OFDb Details",
-                               description=_("Query details from the Online-Filmdatenbank"),
-                               icon="ofdb.png",
-                               where = wherelist,
-                               fnc=main)
+               return [PluginDescriptor(name = "OFDb Details",
+                               description = _("Query details from the Online-Filmdatenbank"),
+                               icon = "ofdb.png",
+                               where = PluginDescriptor.WHERE_PLUGINMENU,
+                               fnc = main),
+                               PluginDescriptor(name = "OFDb Details",
+                               description = _("Query details from the Online-Filmdatenbank"),
+                               where = PluginDescriptor.WHERE_EVENTINFO,
+                               fnc = eventinfo)
+                               ]
        except AttributeError:
                wherelist = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]
                return PluginDescriptor(name="OFDb Details",