From 6e56e8be814305d7a186074efde3d6fe9335f6bb Mon Sep 17 00:00:00 2001 From: Moritz Venn Date: Fri, 16 Jan 2009 13:04:04 +0000 Subject: [PATCH] imdb/ofdb: allow to select different event than the current one in eventinfo hook --- imdb/src/plugin.py | 43 ++++++++++++++++++++++++++++++++++++++----- ofdb/src/plugin.py | 45 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/imdb/src/plugin.py b/imdb/src/plugin.py index c054f53..0550c17 100755 --- a/imdb/src/plugin.py +++ b/imdb/src/plugin.py @@ -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 = """ @@ -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) diff --git a/ofdb/src/plugin.py b/ofdb/src/plugin.py index d94985c..f29fe4a 100644 --- a/ofdb/src/plugin.py +++ b/ofdb/src/plugin.py @@ -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 = """ @@ -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", -- 2.7.4