1 # for localized messages
5 from Components.config import config, ConfigYesNo, ConfigNumber, \
6 ConfigSubsection, ConfigClock
8 # Calculate default begin/end
9 from time import time, localtime, mktime
12 now.tm_year, now.tm_mon, now.tm_mday, 20, 15, \
13 0, now.tm_wday, now.tm_yday, now.tm_isdst)
16 now.tm_year, now.tm_mon, now.tm_mday, 06, 30, \
17 0, now.tm_wday, now.tm_yday, now.tm_isdst)
20 config.plugins.epgrefresh = ConfigSubsection()
21 config.plugins.epgrefresh.enabled = ConfigYesNo(default = False)
22 config.plugins.epgrefresh.begin = ConfigClock(default = int(begin))
23 config.plugins.epgrefresh.end = ConfigClock(default = int(end))
24 config.plugins.epgrefresh.interval = ConfigNumber(default = 2)
25 config.plugins.epgrefresh.delay_standby = ConfigNumber(default = 10)
26 config.plugins.epgrefresh.inherit_autotimer = ConfigYesNo(default = False)
27 config.plugins.epgrefresh.afterevent = ConfigYesNo(default = False)
28 config.plugins.epgrefresh.force = ConfigYesNo(default = False)
29 config.plugins.epgrefresh.wakeup = ConfigYesNo(default = False)
30 config.plugins.epgrefresh.lastscan = ConfigNumber(default = 0)
31 config.plugins.epgrefresh.parse_autotimer = ConfigYesNo(default = False)
36 from EPGRefresh import epgrefresh
37 from EPGRefreshConfiguration import EPGRefreshConfiguration
38 from EPGRefreshService import EPGRefreshService
41 from Plugins.Plugin import PluginDescriptor
43 def standbyQuestionCallback(session, res = None):
45 from Screens.Standby import Standby
49 def autostart(reason, **kwargs):
50 if config.plugins.epgrefresh.enabled.value and reason == 0 \
51 and kwargs.has_key("session"):
53 session = kwargs["session"]
54 if config.plugins.epgrefresh.wakeup.value:
57 (now.tm_year, now.tm_mon, now.tm_mday,
58 config.plugins.epgrefresh.begin.value[0],
59 config.plugins.epgrefresh.begin.value[1],
60 0, now.tm_wday, now.tm_yday, now.tm_isdst)
62 # booted +- 10min from begin of timespan
63 if abs(time() - begin) < 600:
64 from Screens.MessageBox import MessageBox
65 from Tools.Notifications import AddNotificationWithCallback
66 from Tools.BoundFunction import boundFunction
67 # XXX: we use a notification because this will be suppressed otherwise
68 AddNotificationWithCallback(
69 boundFunction(standbyQuestionCallback, session),
71 _("This might have been an automated bootup to refresh the EPG. For this to happen it is recommmended to put the receiver to Standby.\nDo you want to do this now?"),
75 epgrefresh.start(session)
81 # Return invalid time if not automatically refreshing
82 if not config.plugins.epgrefresh.enabled.value or \
83 not config.plugins.epgrefresh.wakeup.value:
89 (now.tm_year, now.tm_mon, now.tm_mday,
90 config.plugins.epgrefresh.begin.value[0],
91 config.plugins.epgrefresh.begin.value[1],
92 0, now.tm_wday, now.tm_yday, now.tm_isdst)
94 # todays timespan has not yet begun
101 def main(session, **kwargs):
103 session.openWithCallback(
105 EPGRefreshConfiguration
108 def doneConfiguring(session, **kwargs):
109 if config.plugins.epgrefresh.enabled.value:
110 epgrefresh.start(session)
113 def eventinfo(session, servicelist, **kwargs):
114 ref = session.nav.getCurrentlyPlayingServiceReference()
117 sref = ref.toString()
118 # strip all after last :
119 pos = sref.rfind(':')
123 epgrefresh.services[0].add(EPGRefreshService(str(sref), None))
125 def Plugins(**kwargs):
130 PluginDescriptor.WHERE_AUTOSTART,
131 PluginDescriptor.WHERE_SESSIONSTART
134 wakeupfnc = getNextWakeup
138 description = _("Automated EPGRefresher"),
139 where = PluginDescriptor.WHERE_PLUGINMENU,
143 name = _("Add to EPGRefresh"),
144 where = PluginDescriptor.WHERE_EVENTINFO,