add workaround to make sure box is running when timespam begins,
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Mon, 24 Dec 2007 13:10:08 +0000 (13:10 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Mon, 24 Dec 2007 13:10:08 +0000 (13:10 +0000)
remove "wip"-comments

epgrefresh/src/EPGRefresh.py
epgrefresh/src/EPGRefreshTimer.py
epgrefresh/src/plugin.py

index 317bac0..dc20ffa 100644 (file)
@@ -23,7 +23,7 @@ from Components.config import config
 CONFIG = "/etc/enigma2/epgrefresh.conf"
 
 class EPGRefresh:
-       """WIP - Simple Class to refresh EPGData - WIP"""
+       """Simple Class to refresh EPGData"""
 
        def __init__(self):
                # Initialize 
@@ -223,4 +223,4 @@ class EPGRefresh:
                        # Clean up
                        self.cleanUp()
 
-epgrefresh = EPGRefresh()
\ No newline at end of file
+epgrefresh = EPGRefresh()
index e63a7ab..085f0a9 100644 (file)
@@ -156,4 +156,4 @@ class EPGRefreshTimer(timer.Timer):
        def isActive(self):
                return len(self.timer_list) > 0
 
-epgrefreshtimer = EPGRefreshTimer()
\ No newline at end of file
+epgrefreshtimer = EPGRefreshTimer()
index 8bfb827..2f5bb19 100644 (file)
@@ -1,10 +1,7 @@
-#
-# Warning: This Plugin is WIP
-#
-
 # Config
 from Components.config import config, ConfigEnableDisable, ConfigInteger, ConfigSubsection, ConfigClock
 
+# Calculate default begin/end
 from time import localtime, mktime
 now = [x for x in localtime()]
 now[3] = 20
@@ -37,8 +34,52 @@ from Plugins.Plugin import PluginDescriptor
 def autostart(reason, **kwargs):
        if config.plugins.epgrefresh.enabled.value and reason == 0 and kwargs.has_key("session"):
                epgrefresh.start(kwargs["session"])
+
+               # Remove a fake timer we might have created at last shutdown
+               for record in kwargs["session"].nav.RecordTimer.timer_list:
+                       if record.name == "EPGRefresh Help Timer":
+                               kwargs["session"].nav.RecordTimer.removeEntry(record)
+                               break
        elif reason == 1:
                epgrefresh.stop()
+               if config.plugins.epgrefresh.enabled.value:
+                       # Workaround until a better solution comes up:
+                       # add a fake zap-timer if the box might not be up when our timespan begins
+
+                       #get next record timer start time
+                       nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
+                       #get next zap timer start time
+                       nextZapTime = session.nav.RecordTimer.getNextZapTime()
+                       if nextZapTime != -1 and nextRecordingTime != -1:
+                               startTime = nextZapTime < nextRecordingTime and nextZapTime or nextRecordingTime
+                       else:
+                               startTime = nextZapTime != -1 and nextZapTime or nextRecordingTime
+
+                       now = localtime()
+                       begin = mktime(
+                               (now.tm_year, now.tm_mon, now.tm_mday,
+                               config.plugins.epgrefresh.begin.value[0],
+                               config.plugins.epgrefresh.begin.value[1],
+                               0, now.tm_wday, now.tm_yday, now.tm_isdst)
+                       )
+
+                       # If no recording scheduled or next scheduled recording after begin of timespan
+                       if startTime == -1 or startTime > begin:
+                               from RecordTimer import RecordTimerEntry
+                               from ServiceReference import ServiceReference
+                               import NavigationInstance
+                               fakeEntry = RecordTimerEntry(
+                                       ServiceReference(
+                                               NavigationInstance.instance.getCurrentlyPlayingServiceReference()
+                                       ),
+                                       begin,
+                                       begin,
+                                       "EPGRefresh Help Timer",
+                                       "EPGRefresh Help Timer",
+                                       -1,
+                                       justplay = True
+                               )
+                               NavigationInstance.instance.RecordTimer.record(fakeEntry)
 
 # Mainfunction
 def main(session, **kwargs):
@@ -56,4 +97,4 @@ def Plugins(**kwargs):
        return [
                PluginDescriptor(name="EPGRefresh", description = "Automated EPGRefresher", where = [PluginDescriptor.WHERE_AUTOSTART, PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart),
                PluginDescriptor(name="EPGRefresh", description = "Automated EPGRefresher", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main)
-       ]
\ No newline at end of file
+       ]