diff --git a/default.py b/default.py
index f457033..2b3dba7 100644
--- a/default.py
+++ b/default.py
@@ -78,7 +78,9 @@
"ShowBookings", "ShowGoalscorer")
SETTINGS_NOTIFICATION_TIME = ("DisplayTime", )
SETTINGS_LEAGUES = ("watchedleagues", )
+SETTING_REFRESH = ("RefreshTime", )
+REFRESH_INTERVALS = (60, 90, 120, 150, 180, 300, 600, 900)
class SettingsMonitor(xbmc.Monitor):
'''Handler to checking when settings are updated and triggering an
@@ -128,6 +130,7 @@ def __init__(self):
self.DETAILED = -1
self.NOTIFY_TIME = -1
self.ADVANCED_NOTIFICATIONS = -1
+ self.REFRESH_TIME = 12
self.updated_needed = False
@@ -182,6 +185,9 @@ def getSettings(self):
if any(x in SETTINGS_NOTIFICATION_TIME for x in self.config._updated):
self.checkNotificationTime()
+ if any(x in SETTING_REFRESH for x in self.config._updated):
+ self.checkRefreshTime()
+
def checkNotificationTime(self):
'''Sets the length of time for which notifications should be
displayed.
@@ -198,6 +204,19 @@ def checkNotificationTime(self):
self.NOTIFY_TIME = n * 1000
self.queue.timeout = self.NOTIFY_TIME
+ def checkRefreshTime(self):
+ '''Sets the time required between updates'''
+ try:
+ idx = int(self.config.RefreshTime)
+ except ValueError:
+ idx = 0
+
+ interval = REFRESH_INTERVALS[idx]
+
+ debug("Update interval is now {} seconds.".format(interval))
+
+ self.REFRESH_TIME = interval / 5
+
def checkAlerts(self):
'''Setting is "True" when alerts are disabled.
'''
@@ -333,78 +352,6 @@ def checkMatch(self, match):
debug(u"Match needs processing... {}".format(repr(match)))
self.queue.add(match)
- # if match.booking:
- #
- # # Should we show notification?
- # if (self.SHOW_YELLOW and self.DETAILED):
- # debug(u"yellow card: {}".format(match.LastYellowCard))
- # try:
- # yellow = u" {1} ({0})".format(*match.LastYellowCard)
- # except AttributeError:
- # yellow = None
- # else:
- # yellow = None
- #
- # if self.SHOW_YELLOW:
- #
- # self.Notify(u"YELLOW!{0}".format(yellow if yellow else u""),
- # unicode(match),
- # IMG_YELLOW,
- # timeout=self.NOTIFY_TIME)
- # debug(u"Yellow Card: {}, {}".format(match, yellow))
- #
- # if match.redcard:
- #
- # # Should we show notification?
- # if (self.SHOW_RED and self.DETAILED):
- # debug(u"red card: {}".format(match.LastRedCard))
- # try:
- # red = u" {1} ({0})".format(*match.LastRedCard)
- # except AttributeError:
- # red = None
- # else:
- # red = None
- #
- # if self.SHOW_RED:
- #
- # self.Notify(u"RED!{0}".format(red if red else u""),
- # unicode(match),
- # IMG_RED,
- # timeout=self.NOTIFY_TIME)
- # debug(u"Red Card: {}, {}".format(match, red))
- #
- # # Has there been a goal?
- # if match.Goal:
- #
- # # Gooooooooooooooooooooooooooooollllllllllllllll!
- #
- # # Should we show goalscorer?
- # if (self.SHOW_GOALSCORER and self.DETAILED):
- # debug(u"goalscorer: {}".format(match.LastGoalScorer))
- # try:
- # scorer = u" {0}".format(match.LastGoalScorer[1])
- # except AttributeError:
- # scorer = None
- # else:
- # scorer = None
- #
- # self.Notify(u"GOAL!{0}".format(scorer if scorer else u""),
- # unicode(match),
- # IMG_GOAL,
- # timeout=self.NOTIFY_TIME)
- # debug(u"GOAL: {}, {}".format(match, scorer))
- #
- # # Has the status changed? e.g. kick-off, half-time, full-time?
- # if match.StatusChanged:
- #
- # # Get the relevant status info
- # info = STATUS_DICT.get(match.status, STATUS_DICT["Fixture"])
- #
- # # Send the notification
- # self.Notify(info[0], unicode(match), info[1],
- # timeout=self.NOTIFY_TIME)
- # debug(u"STATUS: {0}".format(unicode(match)))
-
def checkTickers(self):
'''Tickers are not a class property because they are implemented by a
separate script.
@@ -458,8 +405,6 @@ def doUpdates(self):
Takes one argument:
self.matchdict: dictionary of leagues being watchedleagues
-
- Returns updated dictionary
'''
ticker = u""
@@ -524,7 +469,7 @@ def run(self):
self.updated_needed = False
# If user wants alerts and we've reached our desired loop number...
- if self.SHOW_ALERTS and not i:
+ if not i:
# Update our match dictionary and check for updates.
debug("Checking scores...")
@@ -540,9 +485,8 @@ def run(self):
#xbmc.sleep(5000)
# Increment our counter
- # 12 x 5000 = 60,000 i.e. scores update every 1 minute
- # Currently hard-coded - may look to change this.
- i = (i + 1) % 12
+ # will equal 0 when we hit our desired refresh time.
+ i = (i + 1) % self.REFRESH_TIME
if __name__ == "__main__":
diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po
index 91752cd..b71fcc1 100644
--- a/resources/language/English/strings.po
+++ b/resources/language/English/strings.po
@@ -34,6 +34,10 @@ msgctxt "#32003"
msgid "Notification display time (secs)"
msgstr ""
+msgctxt "#32004"
+msgid "Update interval (secs)"
+msgstr ""
+
#empty ids from 32003 through 32019
#settings script messages
diff --git a/resources/settings.xml b/resources/settings.xml
index 6f6b70c..da12200 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -7,6 +7,7 @@
+