fix typo,
[enigma2-plugins.git] / epgsearch / src / plugin.py
1 # for localized messages         
2 from . import _
3
4 from enigma import eServiceCenter
5
6 # Config
7 from Components.config import config, ConfigSet, ConfigSubsection, ConfigText
8
9 config.plugins.epgsearch = ConfigSubsection()
10 config.plugins.epgsearch.history = ConfigSet(choices = [])
11 # XXX: configtext is more flexible but we cannot use this for a (not yet created) gui config
12 config.plugins.epgsearch.encoding = ConfigText(default = 'ISO8859-15', fixed_size = False)
13
14 # Plugin
15 from EPGSearch import EPGSearch, EPGSearchEPGSelection, EPGSelectionInit
16
17 # Plugin definition
18 from Plugins.Plugin import PluginDescriptor
19
20 # Autostart
21 def autostart(reason, **kwargs):
22         try:
23                 # for blue key activating in EPGSelection
24                 EPGSelectionInit()
25         except Exception:
26                 pass
27
28 # Mainfunction
29 def main(session, *args, **kwargs):
30         s = session.nav.getCurrentService()
31         if s:
32                 info = s.info()
33                 event = info.getEvent(0) # 0 = now, 1 = next
34                 name = event and event.getEventName() or ''
35                 session.open(EPGSearch, name, False)
36         else:
37                 session.open(EPGSearch)
38
39 # Event Info
40 def eventinfo(session, *args, **kwargs):
41         ref = session.nav.getCurrentlyPlayingServiceReference()
42         session.open(EPGSearchEPGSelection, ref, True)
43
44 # Movielist
45 def movielist(session, service, **kwargs):
46         serviceHandler = eServiceCenter.getInstance()
47         info = serviceHandler.info(service)
48         name = info and info.getName(service) or ''
49
50         session.open(EPGSearch, name)
51
52 def Plugins(**kwargs):
53         return [
54                 PluginDescriptor(
55                         where = PluginDescriptor.WHERE_SESSIONSTART,
56                         fnc = autostart,
57                 ),
58                 PluginDescriptor(
59                         name = "EPGSearch",
60                         description = _("Search EPG"),
61                         where = PluginDescriptor.WHERE_PLUGINMENU,
62                         fnc = main,
63                 ),
64                 PluginDescriptor(
65                         name = _("search EPG..."),
66                         where = PluginDescriptor.WHERE_EVENTINFO,
67                         fnc = eventinfo,
68                 ),
69                 PluginDescriptor(
70                         name = "EPGSearch",
71                         description = _("search EPG..."),
72                         where = PluginDescriptor.WHERE_MOVIELIST,
73                         fnc = movielist,
74                 ),
75         ]