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