i3pystatus.scores.nba: Detect and properly display postponed games (#830)
Thanks, COVID! 👍
This commit is contained in:
parent
ad477a6b2a
commit
c07495778b
@ -102,6 +102,7 @@ class NBA(ScoresBackend):
|
|||||||
('format_pregame', 'Format used when the game has not yet started'),
|
('format_pregame', 'Format used when the game has not yet started'),
|
||||||
('format_in_progress', 'Format used when the game is in progress'),
|
('format_in_progress', 'Format used when the game is in progress'),
|
||||||
('format_final', 'Format used when the game is complete'),
|
('format_final', 'Format used when the game is complete'),
|
||||||
|
('format_postponed', 'Format used when the game has been postponed'),
|
||||||
('team_colors', 'Dictionary mapping team abbreviations to hex color '
|
('team_colors', 'Dictionary mapping team abbreviations to hex color '
|
||||||
'codes. If overridden, the passed values will be '
|
'codes. If overridden, the passed values will be '
|
||||||
'merged with the defaults, so it is not necessary to '
|
'merged with the defaults, so it is not necessary to '
|
||||||
@ -160,6 +161,7 @@ class NBA(ScoresBackend):
|
|||||||
format_no_games = 'NBA: No games'
|
format_no_games = 'NBA: No games'
|
||||||
format_pregame = '[{scroll} ]NBA: [{away_favorite} ][{away_seed} ]{away_abbrev} ({away_wins}-{away_losses}) at [{home_favorite} ][{home_seed} ]{home_abbrev} ({home_wins}-{home_losses}) {start_time:%H:%M %Z}'
|
format_pregame = '[{scroll} ]NBA: [{away_favorite} ][{away_seed} ]{away_abbrev} ({away_wins}-{away_losses}) at [{home_favorite} ][{home_seed} ]{home_abbrev} ({home_wins}-{home_losses}) {start_time:%H:%M %Z}'
|
||||||
format_in_progress = '[{scroll} ]NBA: [{away_favorite} ]{away_abbrev} {away_score}[ ({away_power_play})], [{home_favorite} ]{home_abbrev} {home_score}[ ({home_power_play})] ({time_remaining} {quarter})'
|
format_in_progress = '[{scroll} ]NBA: [{away_favorite} ]{away_abbrev} {away_score}[ ({away_power_play})], [{home_favorite} ]{home_abbrev} {home_score}[ ({home_power_play})] ({time_remaining} {quarter})'
|
||||||
|
format_postponed = '[{scroll} ]MLB: [{away_favorite} ]{away_abbrev} ({away_wins}-{away_losses}) at [{home_favorite} ]{home_abbrev} ({home_wins}-{home_losses}) PPD'
|
||||||
format_final = '[{scroll} ]NBA: [{away_favorite} ]{away_abbrev} {away_score} ({away_wins}-{away_losses}) at [{home_favorite} ]{home_abbrev} {home_score} ({home_wins}-{home_losses}) (Final[/{overtime}])'
|
format_final = '[{scroll} ]NBA: [{away_favorite} ]{away_abbrev} {away_score} ({away_wins}-{away_losses}) at [{home_favorite} ]{home_abbrev} {home_score} ({home_wins}-{home_losses}) (Final[/{overtime}])'
|
||||||
team_colors = _default_colors
|
team_colors = _default_colors
|
||||||
live_url = LIVE_URL
|
live_url = LIVE_URL
|
||||||
@ -206,19 +208,22 @@ class NBA(ScoresBackend):
|
|||||||
_update('id', 'gameId')
|
_update('id', 'gameId')
|
||||||
ret['live_url'] = self.live_url.format(id=ret['id'])
|
ret['live_url'] = self.live_url.format(id=ret['id'])
|
||||||
|
|
||||||
status_map = {
|
if game.get('gameStatusText', '') == 'PPD':
|
||||||
1: 'pregame',
|
ret['status'] = 'postponed'
|
||||||
2: 'in_progress',
|
else:
|
||||||
3: 'final',
|
status_map = {
|
||||||
}
|
1: 'pregame',
|
||||||
status_code = int(game.get('gameStatus', 1))
|
2: 'in_progress',
|
||||||
status = status_map.get(status_code)
|
3: 'final',
|
||||||
if status is None:
|
}
|
||||||
self.logger.debug(
|
status_code = int(game.get('gameStatus', 1))
|
||||||
f"Unknown {self.name} game status code '{status_code}'"
|
status = status_map.get(status_code)
|
||||||
)
|
if status is None:
|
||||||
status_code = '1'
|
self.logger.debug(
|
||||||
ret['status'] = status_map[status_code]
|
f"Unknown {self.name} game status code '{status_code}'"
|
||||||
|
)
|
||||||
|
status_code = '1'
|
||||||
|
ret['status'] = status_map[status_code]
|
||||||
|
|
||||||
if ret['status'] in ('in_progress', 'final'):
|
if ret['status'] in ('in_progress', 'final'):
|
||||||
period_number = int(game.get('period', 1))
|
period_number = int(game.get('period', 1))
|
||||||
|
Loading…
Reference in New Issue
Block a user