Skip to content

Competitions

dxstiny edited this page Jul 1, 2022 · 3 revisions

Retrieving all competitions

All competitions that are hidden somewhere on cev.eu (e.g. Champions League, CEV Cup, National Championships, ...) can be retrieved via the Competitions module. The Competitions object will contain all competitions (as links). Please note that the competitions will be cached automatically, meaning a second call will return the exact same Competitions object, just faster. Said link contains the necessary info, such as name, type, gender and href.

from cevlib.competitions import Competitions

competitions = await Competitions.getAll() # get all competitions (Competitions object)
print( competitions )

link = competitions.get(0) # get the first competition (CompetitionLink object)
print( link )

Retrieving a competition

Every CompetitionLink can then be used to retrieve a (full) competition:

import asyncio
from cevlib.competitions import Competitions, Competition

async def main():
    competitions = await Competitions.getAll() # get all competitions (Competitions object)
    print( competitions )

    link = competitions.get(0) # get the first competition (CompetitionLink object)
    print( link )

    assert link
    competition = await link.toCompetition()
    print( competition )

    # or
    competition = await Competition.fromUrl(link.href) # get the first competition (Competition object)
    print( competition )

    assert competition
    round = competition.get(1) # get the first round (Round object)
    print( round )

    assert round
    pool = round.get(0) # get the first pool (Pool object)
    print( pool )

    assert pool
    standingsPool = pool.standingsPool # get this pool's standings (StandingsPool object)
    print( standingsPool )

    assert pool
    draw = pool.get(0) # get the first draw (Draw object)
    print( draw )

    assert draw
    match = draw.get(0) # get the first match (CalendarMatch object)
    print ( match )

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