-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandascore-dota.py
36 lines (26 loc) · 1.34 KB
/
pandascore-dota.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from datetime import datetime, timedelta
import requests
url = "https://api.pandascore.co/dota2/tournaments/running?sort=&page=1&per_page=50"
headers = {
"accept": "application/json",
"Authorization": "gkuzT3vQrwVmxr6GLwZrDGjySh6t514Jgc-YgTnuuvA2RAW0IU4"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
ongoing_tournaments = response.json()
for tournament in ongoing_tournaments:
print(f"Tournament: {tournament['name']}")
matches_url = f"https://api.pandascore.co/dota2/matches/upcoming?filter[tournament_id]={tournament['id']}&range[begin_at]=,{datetime.utcnow().isoformat()}Z&range[end_at]={(datetime.utcnow() + timedelta(days=1)).isoformat()}Z"
matches_response = requests.get(matches_url, headers=headers)
if matches_response.status_code == 200:
upcoming_matches = matches_response.json()
if not upcoming_matches:
print("No upcoming matches today.")
else:
for match in upcoming_matches:
print(f"Match: {match['name']} - Scheduled at: {match['begin_at']}")
else:
print(f"Request failed with status code {matches_response.status_code}")
print("\n")
else:
print(f"Request failed with status code {response.status_code}")