pga and lpga rankings added (team stats)
This commit is contained in:
parent
48ec140f31
commit
4fb8cc68ec
@ -791,30 +791,55 @@ def updateLeagueTables(api_key, logf):
|
|||||||
|
|
||||||
all_data = r.json()
|
all_data = r.json()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i,l in enumerate(all_data):
|
for i,l in enumerate(all_data):
|
||||||
|
|
||||||
league = list(l.keys())[0]
|
league = list(l.keys())[0]
|
||||||
|
|
||||||
|
|
||||||
teams = []
|
teams = []
|
||||||
|
if league == 'pga' or league == 'lpga':
|
||||||
|
logo_files = []
|
||||||
for d in all_data[i][league]:
|
for d in all_data[i][league]:
|
||||||
team = {}
|
del d['_id'], d['updated']
|
||||||
|
teams.append(d)
|
||||||
|
try:
|
||||||
|
if d['country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
|
||||||
team['name'] = d['strTeam']
|
urllib.request.urlretrieve(d['country'], 'logos/ufc_countries/' + d['country'].split('/')[-1].split('&')[0])
|
||||||
team['wins'] = d['intWin']
|
except:
|
||||||
team['loss'] = d['intLoss']
|
pass
|
||||||
team['draw'] = d['intDraw']
|
try:
|
||||||
#team['played'] = d['intPlayed']
|
if league == 'pga':
|
||||||
team['standing'] = d['intRank']
|
if d['photo'].split('/')[-1].split('&')[0] not in os.listdir('logos/pga_rank/'):
|
||||||
#team['points'] = d['intPoints']
|
urllib.request.urlretrieve(d['photo'],'logos/pga_rank/' + d['photo'].split('/')[-1].split('&')[0])
|
||||||
|
elif league == 'lpga':
|
||||||
teams.append(team)
|
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
|
leagues_info[league.upper()] = teams
|
||||||
|
|
||||||
all_settings['leagues'] = leagues_info
|
all_settings['leagues'] = leagues_info
|
||||||
|
Loading…
Reference in New Issue
Block a user