i3pystatus.scores.nba: Fix spurious log warning for games that haven't started (#827)

This commit is contained in:
Erik Johnson 2021-12-16 09:46:12 -06:00 committed by GitHub
parent 48775e4b87
commit 8476fd6a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -232,19 +232,20 @@ class NBA(ScoresBackend):
ret['quarter'] = ''
clock = game.get('gameClock', '')
try:
mins, secs = re.match(r'^PT(\d+)M(\d+\.\d)0?S$', clock).groups()
except AttributeError:
ret['time_remaining'] = ''
self.logger.warning('Failed to parse gameClock value: {clock}')
else:
mins = mins.lstrip('0')
if mins:
secs = secs.split('.')[0]
if not mins and secs == '00.0':
ret['time_remaining'] = 'End'
ret['time_remaining'] = ''
if clock:
try:
mins, secs = re.match(r'^PT(\d+)M(\d+\.\d)0?S$', clock).groups()
except AttributeError:
self.logger.warning(f'Failed to parse gameClock value: {clock}')
else:
ret['time_remaining'] = f'{mins}:{secs}'
mins = mins.lstrip('0')
if mins:
secs = secs.split('.')[0]
if not mins and secs == '00.0':
ret['time_remaining'] = 'End'
else:
ret['time_remaining'] = f'{mins}:{secs}'
ret['overtime'] = ret['quarter'] if 'OT' in ret['quarter'] else ''