revert broken workaround, waiting for a better solution
[enigma2-plugins.git] / epgrefresh / src / plugin.py
1 # Config
2 from Components.config import config, ConfigEnableDisable, ConfigInteger, ConfigSubsection, ConfigClock
3
4 # Calculate default begin/end
5 from time import localtime, mktime
6 now = [x for x in localtime()]
7 now[3] = 20
8 now[4] = 15
9 begin = mktime(now)
10 now[3] = 06
11 now[4] = 30
12 end = mktime(now)
13
14 config.plugins.epgrefresh = ConfigSubsection()
15 config.plugins.epgrefresh.enabled = ConfigEnableDisable(default = False)
16 config.plugins.epgrefresh.begin = ConfigClock(default = begin)
17 config.plugins.epgrefresh.end = ConfigClock(default = end)
18 config.plugins.epgrefresh.interval = ConfigInteger(default = 2, limits=(1, 10))
19 config.plugins.epgrefresh.delay_timespan = ConfigInteger(default = 60, limits=(5, 300))
20 config.plugins.epgrefresh.delay_standby = ConfigInteger(default = 10, limits=(1, 60))
21 config.plugins.epgrefresh.inherit_autotimer = ConfigEnableDisable(default = False)
22 config.plugins.epgrefresh.afterevent = ConfigEnableDisable(default = False)
23 config.plugins.epgrefresh.force = ConfigEnableDisable(default = False)
24 config.plugins.epgrefresh.lastscan = ConfigInteger(default = 0)
25
26 # Plugin
27 from EPGRefresh import epgrefresh
28 from EPGRefreshConfiguration import EPGRefreshConfiguration
29
30 # Plugin definition
31 from Plugins.Plugin import PluginDescriptor
32
33 # Autostart
34 def autostart(reason, **kwargs):
35         if config.plugins.epgrefresh.enabled.value and reason == 0 and kwargs.has_key("session"):
36                 epgrefresh.start(kwargs["session"])
37
38         elif reason == 1:
39                 epgrefresh.stop()
40
41 # Mainfunction
42 def main(session, **kwargs):
43         epgrefresh.stop()
44         session.openWithCallback(
45                 doneConfiguring,
46                 EPGRefreshConfiguration
47         )
48
49 def doneConfiguring(session, **kwargs):
50         if config.plugins.epgrefresh.enabled.value:
51                 epgrefresh.start(session)
52
53 def Plugins(**kwargs):
54         return [
55                 PluginDescriptor(name="EPGRefresh", description = "Automated EPGRefresher", where = [PluginDescriptor.WHERE_AUTOSTART, PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart),
56                 PluginDescriptor(name="EPGRefresh", description = "Automated EPGRefresher", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main)
57         ]