pga and lpga rankings added (team stats)

This commit is contained in:
Justin 2023-05-05 15:58:51 +08:00 committed by GitHub
parent 48ec140f31
commit 4fb8cc68ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -791,30 +791,55 @@ def updateLeagueTables(api_key, logf):
all_data = r.json()
for i,l in enumerate(all_data):
league = list(l.keys())[0]
teams = []
for d in all_data[i][league]:
team = {}
team['name'] = d['strTeam']
team['wins'] = d['intWin']
team['loss'] = d['intLoss']
team['draw'] = d['intDraw']
#team['played'] = d['intPlayed']
team['standing'] = d['intRank']
#team['points'] = d['intPoints']
teams.append(team)
if league == 'pga' or league == 'lpga':
logo_files = []
for d in all_data[i][league]:
del d['_id'], d['updated']
teams.append(d)
try:
if d['country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
urllib.request.urlretrieve(d['country'], 'logos/ufc_countries/' + d['country'].split('/')[-1].split('&')[0])
except:
pass
try:
if league == 'pga':
if d['photo'].split('/')[-1].split('&')[0] not in os.listdir('logos/pga_rank/'):
urllib.request.urlretrieve(d['photo'],'logos/pga_rank/' + d['photo'].split('/')[-1].split('&')[0])
elif league == 'lpga':
if d['photo'].split('/')[-1] not in os.listdir('logos/lpga_rank/'):
urllib.request.urlretrieve(d['photo'],'logos/lpga_rank/' + d['photo'].split('/')[-1])
except:
pass
try:
if league == 'pga':
logo_files.append(d['photo'].split('/')[-1].split('&')[0])
elif league == 'lpga':
logo_files.append(d['photo'].split('/')[-1])
except:
pass
if league == 'pga':
for file in os.listdir('logos/pga_rank/'):
if file not in logo_files:
os.remove('logos/pga_rank/'+ file)
elif league == 'lpga':
for file in os.listdir('logos/lpga_rank/'):
if file not in logo_files:
os.remove('logos/lpga_rank/'+ file)
else:
for d in all_data[i][league]:
team = {}
team['name'] = d['strTeam']
team['wins'] = d['intWin']
team['loss'] = d['intLoss']
team['draw'] = d['intDraw']
#team['played'] = d['intPlayed']
team['standing'] = d['intRank']
#team['points'] = d['intPoints']
teams.append(team)
leagues_info[league.upper()] = teams
all_settings['leagues'] = leagues_info