Files
pcs_live/example.py

23 lines
696 B
Python
Raw Normal View History

2026-05-30 18:39:09 +01:00
from pcslive import LiveStats
import time
2026-05-30 18:39:09 +01:00
stats = LiveStats()
2026-05-30 20:52:47 +01:00
# if there are live races...
2026-05-30 18:39:09 +01:00
if len(stats.races) > 0:
2026-05-30 20:52:47 +01:00
race = stats.races[0] # just grab the first one for example's sake
2026-05-30 18:39:09 +01:00
print("Latest timeline update from", race.title, ":")
2026-05-30 20:52:47 +01:00
# keep the last update so we don't spam the terminal
last_update = ""
while True:
race.get_timeline()
2026-05-30 20:52:47 +01:00
# 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]
2026-05-30 20:52:47 +01:00
# wait ten seconds before checking again
# maybe set to longer if running for extended time
time.sleep(10)