Skip to content

Score observers

dxstiny edited this page Jul 1, 2022 · 2 revisions

You can observe the score of any match object by adding a callback:

import asyncio

from cevlib.match import Match
from cevlib.types.results import Result

async def main():
    match = await Match.byUrl("https://www.cev.eu/match-centres/2022-european-cups/cev-volleyball-cup-2022-women/ccw-54-mladost-zagreb-v-lks-commercecon-lodz/")

    await match.init()
    async def callback(x: Match, score: Result):
        print(score)
        print(await x.duration())

    match.addScoreObserver(callback)
    match.setScoreObserverInterval(10) # OPTIONAL: sets the polling interval to 10s, 20s by default

    while True:
        await asyncio.sleep(1)

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
Clone this wiki locally