cleanup
[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 Esception:
26                 pass
27
28 # Mainfunction
29 def main(session, *args, **kwargs):
30         s = session.nav.getCurrentService()
31         info = s.info()
32         event = info.getEvent(0) # 0 = now, 1 = next
33         name = event and event.getEventName() or ''
34         session.open(EPGSearch, name, False)
35
36 # Event Info
37 def eventinfo(session, *args, **kwargs):
38         ref = session.nav.getCurrentlyPlayingServiceReference()
39         session.open(EPGSearchEPGSelection, ref, True)
40
41 # Movielist
42 def movielist(session, service, **kwargs):
43         serviceHandler = eServiceCenter.getInstance()
44         info = serviceHandler.info(service)
45         name = info and info.getName(service) or ''
46
47         session.open(EPGSearch, name)
48
49 def Plugins(**kwargs):
50         return [
51                 PluginDescriptor(
52                         where = PluginDescriptor.WHERE_SESSIONSTART,
53                         fnc = autostart,
54                 ),
55                 PluginDescriptor(
56                         name = "EPGSearch",
57                         description = _("Search EPG"),
58                         where = PluginDescriptor.WHERE_PLUGINMENU,
59                         fnc = main,
60                 ),
61                 PluginDescriptor(
62                         name = _("search EPG..."),
63                         where = PluginDescriptor.WHERE_EVENTINFO,
64                         fnc = eventinfo,
65                 ),
66                 PluginDescriptor(
67                         name = "EPGSearch",
68                         description = _("search EPG..."),
69                         where = PluginDescriptor.WHERE_MOVIELIST,
70                         fnc = movielist,
71                 ),
72         ]