Skip to content

Commit 229f60e

Browse files
committed
feat: update tournament matches example to use current stage and add new stages example
1 parent 425212c commit 229f60e

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

examples/promiedos/tournament_matches.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
# print some info
2828
print(tournament.league.name, tournament.league.slug)
2929

30-
# Get the current filter for getting the matches
31-
filter: PromiedosTypes.TournamentFilter = tournament.current_filter()
32-
print("Current filter is", filter.name)
30+
# Get the current stage for getting the matches
31+
stage: PromiedosTypes.Stage = tournament.current_stage()
32+
print("Current stage is", stage.name)
3333

3434
# Get the matches for the tournament
3535
matches: list[PromiedosTypes.Match] = client.get_tournament_matchs(
36-
tournament.league.id, filter.id
36+
tournament.league.id, stage.id
3737
)
3838

3939
# Print the matches
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
In this example we will get all the stages of a tournament
3+
also we will get the matches of the first stage.
4+
5+
Output example:
6+
7+
Fecha 1 False
8+
Fecha 2 False
9+
Fecha 3 False
10+
Fecha 4 False
11+
Fecha 5 False
12+
Fecha 6 False
13+
Fecha 7 False
14+
Fecha 8 False
15+
Playoff False
16+
Octavos de Final False
17+
Cuartos De Final True
18+
19+
Monaco vs Aston Villa
20+
Atalanta vs Sturm Graz
21+
Slovan Bratislava vs Stuttgart
22+
and more...
23+
24+
"""
25+
from esd import PromiedosClient, PromiedosTypes
26+
27+
client = PromiedosClient()
28+
29+
# "fhc" is the ID of uefa champions league
30+
tournament: PromiedosTypes.Tournament = client.get_tournament("fhc")
31+
32+
# get all stages
33+
stages: list[PromiedosTypes.Stage] = tournament.stages
34+
35+
# print the stages
36+
for stage in stages:
37+
print(stage.name, stage.selected)
38+
39+
# now we will use the first stage
40+
stage = stages[0]
41+
matches = client.get_tournament_matchs(tournament.league.id, stage.id)
42+
for match in matches:
43+
print(match.home_team.name, "vs", match.away_team.name)

0 commit comments

Comments
 (0)