sports bug fixes

This commit is contained in:
Neythen
2021-06-16 19:23:14 +01:00
parent eedb40ac32
commit 1a4ed74c38
12 changed files with 50 additions and 37 deletions

View File

@@ -299,9 +299,9 @@ def updateCurrencies(api_key):
def updateSports(api_key):
url = 'https://www.thesportsdb.com/api/v1/json/1/lookuptable.php?l=4328&s=2020-2021' # premier league table
'https://www.thesportsdb.com/api/v1/json/1/eventsnext.php?id=133602' # next five events by team ID (paid) use this for upcoming team games
'https://www.thesportsdb.com/api/v2/json/APIKEY/livescore.php?l=4380' #live scores
url = 'https://www.thesportsdb.com/api/v1/json/{}/lookuptable.php?l=4328&s=2020-2021'.format(api_key) # premier league table
'https://www.thesportsdb.com/api/v1/json/{}/eventsnext.php?id=133602'.format(api_key) # next five events by team ID (paid) use this for upcoming team games
r = requests.get(url)
all_data = r.json()
@@ -326,7 +326,11 @@ def updateSports(api_key):
json.dump(premier_teams, open( "csv/sports/premier_league/team_stats.json", 'w+' ))
url = 'https://www.thesportsdb.com/api/v1/json/1/eventsseason.php?id=4328&s=2020-2021' # all events in premier league
#url = 'https://www.thesportsdb.com/api/v1/json/{}/eventsseason.php?id=4328&s=2020-2021'.format(api_key) # all past events in premier league
url ='https://www.thesportsdb.com/api/v1/json/{}/eventspastleague.php?id=4328'.format(api_key) #last 15 events on the league (premium only)
print(url)
r = requests.get(url)
all_data = r.json()
@@ -336,9 +340,10 @@ def updateSports(api_key):
events = []
for i in range(len(all_data['events'][i])):
for i in range(len(all_data['events'])):
event = {}
event['date'] = all_data['events'][i]['dateEvent']
print(event['date'])
event['time'] = all_data['events'][i]['strTime']
event['home_team'] = all_data['events'][i]['strHomeTeam']
event['home_score'] = all_data['events'][i]['intHomeScore']
@@ -350,8 +355,13 @@ def updateSports(api_key):
json.dump(events, open( "csv/sports/premier_league/past_games.json", 'w+' ))
url ='https://www.thesportsdb.com/api/v1/json/1/eventsnextleague.php?id=4328' #next 15 events on the league (premium only)
url ='https://www.thesportsdb.com/api/v1/json/{}/eventsnextleague.php?id=4328'.format(api_key) #next 15 events on the league (premium only)
url = 'https://www.thesportsdb.com/api/v2/json/{}/livescore.php?l=4380'.format(api_key) #live scores
print(all_data)
@@ -399,6 +409,9 @@ if __name__ == '__main__':
currency_key = '862dbb6d1101ce0c5136'
sports_key = '97436974'
updateSports(sports_key)
sys.exit()
updateCurrencies(currency_key)