27 lines
520 B
Python
27 lines
520 B
Python
import requests
|
|
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
ESPN_URL = str(os.getenv("ESPN_URL"))
|
|
|
|
|
|
def get_game_data():
|
|
res = requests.get(ESPN_URL).json()
|
|
return res["events"]
|
|
|
|
|
|
def get_team_game(team, games):
|
|
found_team = None
|
|
|
|
for game in games:
|
|
competition = game["competitions"][0]
|
|
found_team = filter(lambda c: c.team.abbrevation.lower() == team,
|
|
competition["competitors"])
|
|
|
|
if found_team:
|
|
break
|
|
|
|
return found_team
|
|
|