initial checkin of MerlinSkinThemes
[enigma2-plugins.git] / epgsearch / src / plugin.py
1 from enigma import eServiceCenter
2
3 # Plugin
4 from EPGSearch import EPGSearch, EPGSearchEPGSelection, EPGSelectionInit
5
6 # Plugin definition
7 from Plugins.Plugin import PluginDescriptor
8
9 # Autostart
10 def autostart(reason, **kwargs):
11         if reason == 0:
12                 try:
13                         # for blue key activating in EPGSelection
14                         EPGSelectionInit()
15                 except Exception:
16                         pass
17
18 # Mainfunction
19 def main(session, *args, **kwargs):
20         s = session.nav.getCurrentService()
21         if s:
22                 info = s.info()
23                 event = info.getEvent(0) # 0 = now, 1 = next
24                 name = event and event.getEventName() or ''
25                 session.open(EPGSearch, name, False)
26         else:
27                 session.open(EPGSearch)
28
29 # Event Info
30 def eventinfo(session, *args, **kwargs):
31         ref = session.nav.getCurrentlyPlayingServiceReference()
32         session.open(EPGSearchEPGSelection, ref, True)
33
34 # Movielist
35 def movielist(session, service, **kwargs):
36         serviceHandler = eServiceCenter.getInstance()
37         info = serviceHandler.info(service)
38         name = info and info.getName(service) or ''
39
40         session.open(EPGSearch, name)
41
42 def Plugins(**kwargs):
43         return [
44                 PluginDescriptor(
45                         where = PluginDescriptor.WHERE_AUTOSTART,
46                         fnc = autostart,
47                         needsRestart = False,
48                 ),
49                 PluginDescriptor(
50                         name = "EPGSearch",
51                         # TRANSLATORS: description of EPGSearch in PluginBrowser
52                         description = _("Search EPG"),
53                         where = PluginDescriptor.WHERE_PLUGINMENU,
54                         fnc = main,
55                         needsRestart = False,
56                 ),
57                 PluginDescriptor(
58                         # TRANSLATORS: EPGSearch title in EventInfo dialog (requires the user to select an event to search for)
59                         name = _("search EPG..."),
60                         where = PluginDescriptor.WHERE_EVENTINFO,
61                         fnc = eventinfo,
62                         needsRestart = False,
63                 ),
64                 PluginDescriptor(
65                         # TRANSLATORS: EPGSearch title in MovieList (does not require further user interaction)
66                         description = _("search EPG"),
67                         where = PluginDescriptor.WHERE_MOVIELIST,
68                         fnc = movielist,
69                         needsRestart = False,
70                 ),
71         ]