comments
This commit is contained in:
10
example.py
10
example.py
@@ -3,15 +3,21 @@ import time
|
||||
|
||||
stats = LiveStats()
|
||||
|
||||
# if there are live races...
|
||||
if len(stats.races) > 0:
|
||||
race = stats.races[0]
|
||||
race = stats.races[0] # just grab the first one for example's sake
|
||||
print("Latest timeline update from", race.title, ":")
|
||||
|
||||
|
||||
# keep the last update so we don't spam the terminal
|
||||
last_update = ""
|
||||
while True:
|
||||
race.get_timeline()
|
||||
|
||||
# only update terminal if the newest item has changed (is new)
|
||||
if last_update != race.timeline[0]:
|
||||
print(race.timeline[0])
|
||||
last_update = race.timeline[0]
|
||||
|
||||
# wait ten seconds before checking again
|
||||
# maybe set to longer if running for extended time
|
||||
time.sleep(10)
|
||||
Reference in New Issue
Block a user