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