examples named

This commit is contained in:
cube
2026-05-30 21:43:47 +01:00
parent 14347d7633
commit 1e665d45b7
4 changed files with 18 additions and 6 deletions

23
example_live_timeline.py Normal file
View File

@@ -0,0 +1,23 @@
from pcslive import LiveStats
import time
stats = LiveStats()
# if there are live races...
if len(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)