Skip to content

Commit 3e2a344

Browse files
authored
Merge pull request #2325 from eracknaphobia/script.nhlscores@matrix
[script.nhlscores@matrix] 2022.10.5+matrix.1
2 parents 03fcbee + 3f039d9 commit 3e2a344

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

script.nhlscores/addon.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.nhlscores" name="NHL Scores" version="2022.4.30+matrix.1" provider-name="eracknaphobia">
2+
<addon id="script.nhlscores" name="NHL Scores" version="2022.10.5+matrix.1" provider-name="eracknaphobia">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
<import addon="script.module.pytz" />
@@ -12,7 +12,7 @@
1212
<description lang="en_GB">Live scoring and game updates via kodi notifications
1313
</description>
1414
<news>
15-
- Run as service
15+
- Update to f-strings
1616
</news>
1717
<language>en</language>
1818
<platform>all</platform>

script.nhlscores/resources/lib/scores.py

+23-22
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ def check_games_scheduled(self):
9696
sleep_seconds = int((first_game_start - datetime.datetime.utcnow()).total_seconds())
9797
if sleep_seconds >= 6600:
9898
# hour and 50 minutes or more just display hours
99-
delay_time = "%s hours" % round(sleep_seconds / 3600)
99+
delay_time = f" {round(sleep_seconds / 3600)} hours"
100100
elif sleep_seconds >= 4200:
101101
# hour and 10 minutes
102-
delay_time = "an hour and %s minutes" % round((sleep_seconds / 60) - 60)
102+
delay_time = f"an hour and {round((sleep_seconds / 60) - 60)} minutes"
103103
elif sleep_seconds >= 3000:
104104
# 50 minutes
105105
delay_time = "an hour"
106106
else:
107-
delay_time = "%s minutes" % round((sleep_seconds / 60))
107+
delay_time = f"{round((sleep_seconds / 60))} minutes"
108108

109-
message = "First game starts in about %s" % delay_time
109+
message = f"First game starts in about {delay_time}"
110110
self.notify(self.local_string(30300), message)
111111
self.monitor.waitForAbort(sleep_seconds)
112112

@@ -149,7 +149,7 @@ def get_new_stats(self, game):
149149

150150
game_clock = game['status']['detailedState']
151151
if 'in progress' in game_clock.lower():
152-
game_clock = '%s %s' % (game['linescore']['currentPeriodTimeRemaining'], game['linescore']['currentPeriodOrdinal'])
152+
game_clock = f"{game['linescore']['currentPeriodTimeRemaining']} {game['linescore']['currentPeriodOrdinal']}"
153153

154154
# Disable spoiler by not showing score notifications for the game the user is currently watching
155155
if ateam.lower() not in video_playing and hteam.lower() not in video_playing:
@@ -175,45 +175,46 @@ def final_score_message(self, new_item):
175175
# Highlight score of the winning team
176176
title = self.local_string(30355)
177177
if new_item['away_score'] > new_item['home_score']:
178-
away_score = '[COLOR=%s]%s %s[/COLOR]' % (self.score_color, new_item['away_name'], new_item['away_score'])
179-
home_score = '%s %s' % (new_item['home_name'], new_item['home_score'])
178+
away_score = f"[COLOR={self.score_color}]{new_item['away_name']} {new_item['away_score']}[/COLOR]"
179+
home_score = f"{new_item['home_name']} {new_item['home_score']}"
180180
else:
181-
away_score = '%s %s' % (new_item['away_name'], new_item['away_score'])
182-
home_score = '[COLOR=%s]%s %s[/COLOR]' % (self.score_color, new_item['home_name'], new_item['home_score'])
181+
away_score = f"{new_item['away_name']} {new_item['away_score']}"
182+
home_score = f"[COLOR={self.score_color}]{new_item['home_name']} {new_item['home_score']}[/COLOR]"
183183

184-
game_clock = '[COLOR=%s]%s[/COLOR]' % (self.gametime_color, new_item['game_clock'])
185-
message = '%s %s %s' % (away_score, home_score, game_clock)
184+
game_clock = f"[COLOR={self.gametime_color}]{new_item['game_clock']}[/COLOR]"
185+
message = f"{away_score} {home_score} {game_clock}"
186186
return title, message
187187

188188
def game_started_message(self, new_item):
189189
title = self.local_string(30358)
190-
message = '%s vs %s' % (new_item['away_name'], new_item['home_name'])
190+
message = f"{new_item['away_name']} vs {new_item['home_name']}"
191191
return title, message
192192

193193
def period_change_message(self, new_item):
194194
# Notify user that the game has started / period has changed
195195
title = self.local_string(30370)
196-
message = '%s %s %s %s [COLOR=%s]%s has started[/COLOR]' % \
197-
(new_item['away_name'], new_item['away_score'], new_item['home_name'], new_item['home_score'],
198-
self.gametime_color, new_item['period'])
196+
message = f"{new_item['away_name']} {new_item['away_score']} " \
197+
f"{new_item['home_name']} {new_item['home_score']} " \
198+
f"[COLOR={self.gametime_color}]{new_item['period']} has started[/COLOR]"
199+
199200
return title, message
200201

201202
def goal_scored_message(self, new_item, old_item):
202203
# Highlight score for the team that just scored a goal
203-
away_score = '%s %s' % (new_item['away_name'], new_item['away_score'])
204-
home_score = '%s %s' % (new_item['home_name'], new_item['home_score'])
205-
game_clock = '[COLOR=%s]%s[/COLOR]' % (self.gametime_color, new_item['game_clock'])
204+
away_score = f"{new_item['away_name']} {new_item['away_score']}"
205+
home_score = f"{new_item['home_name']} {new_item['home_score']}"
206+
game_clock = f"[COLOR={self.gametime_color}]{new_item['game_clock']}[/COLOR]"
206207

207208
if new_item['away_score'] != old_item['away_score']:
208-
away_score = '[COLOR=%s]%s[/COLOR]' % (self.score_color, away_score)
209+
away_score = f"[COLOR={self.score_color}]{away_score}[/COLOR]"
209210
if new_item['home_score'] != old_item['home_score']:
210-
home_score = '[COLOR=%s]%s[/COLOR]' % (self.score_color, home_score)
211+
home_score = f"[COLOR={self.score_color}]{home_score}[/COLOR]"
211212

212213
if self.addon.getSetting(id="goal_desc") == 'false':
213214
title = self.local_string(30365)
214-
message = '%s %s %s' % (away_score, home_score, game_clock)
215+
message = f"{away_score} {home_score} {game_clock}"
215216
else:
216-
title = '%s %s %s' % (away_score, home_score, game_clock)
217+
title = f"{away_score} {home_score} {game_clock}"
217218
message = new_item['goal_desc']
218219

219220
return title, message

0 commit comments

Comments
 (0)