replaced old golf data with new espn golf data
This commit is contained in:
parent
5c042c9c09
commit
4669a28d85
@ -1071,7 +1071,7 @@ def updateLeagueEvents(api_key, time, logf):
|
|||||||
event['shots_par'] = d['shots_par']
|
event['shots_par'] = d['shots_par']
|
||||||
event['purse'] = d['purse']
|
event['purse'] = d['purse']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
event['event'] = d['strEvent'].replace("\u2019","'")
|
event['event'] = d['strEvent'].replace("\u2019","'")
|
||||||
event['venue'] = d['strVenue'].replace("\u2019","'")
|
event['venue'] = d['strVenue'].replace("\u2019","'")
|
||||||
event['city'] = d['strCity'].replace("\u2019","'")
|
event['city'] = d['strCity'].replace("\u2019","'")
|
||||||
@ -1085,100 +1085,107 @@ def updateLeagueEvents(api_key, time, logf):
|
|||||||
|
|
||||||
if time != 'upcoming':
|
if time != 'upcoming':
|
||||||
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||||
event['golf_standings'] = d['strResult']
|
# event['golf_standings'] = d['strResult']
|
||||||
event['golf_rankings'] = d['player_results']
|
event['golf_rankings'] = d['player_results']
|
||||||
|
for player in event['golf_rankings']:
|
||||||
|
try:
|
||||||
|
if player['country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
|
||||||
|
urllib.request.urlretrieve(player['country'], 'logos/ufc_countries/' + player['country'].split('/')[-1].split('&')[0])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# rank = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'T1', 'T2', 'T3', 'T4', 'T5',
|
||||||
|
# 'T6', 'T7', 'T8', 'T9', 'T10']
|
||||||
|
# def convert(string):
|
||||||
|
# string = repr(string).replace('/', '')
|
||||||
|
# li = list(string.split('\\'))
|
||||||
|
# return li
|
||||||
|
|
||||||
rank = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'T1', 'T2', 'T3', 'T4', 'T5',
|
# str3 = convert(event['golf_standings'])
|
||||||
'T6', 'T7', 'T8', 'T9', 'T10']
|
|
||||||
|
|
||||||
def convert(string):
|
# players = []
|
||||||
string = repr(string).replace('/', '')
|
|
||||||
li = list(string.split('\\'))
|
|
||||||
return li
|
|
||||||
|
|
||||||
str3 = convert(event['golf_standings'])
|
|
||||||
|
|
||||||
players = []
|
|
||||||
|
|
||||||
|
|
||||||
for each in str3:
|
# for each in str3:
|
||||||
each = each.replace('nT', 'T', 1)
|
# each = each.replace('nT', 'T', 1)
|
||||||
if each[:2] in rank:
|
# if each[:2] in rank:
|
||||||
try:
|
# try:
|
||||||
first_space = each.find(' ', 1)
|
# first_space = each.find(' ', 1)
|
||||||
second_space = each.find(' ', 4)
|
# second_space = each.find(' ', 4)
|
||||||
first_name = each[first_space:second_space].lstrip()
|
# first_name = each[first_space:second_space].lstrip()
|
||||||
initial = first_name[0] + '.'
|
# initial = first_name[0] + '.'
|
||||||
each = each.replace(first_name,initial)
|
# each = each.replace(first_name,initial)
|
||||||
except:
|
# except:
|
||||||
pass
|
# pass
|
||||||
interator = each.find('-')
|
# interator = each.find('-')
|
||||||
if interator < 0:
|
# if interator < 0:
|
||||||
interator = 0
|
# interator = 0
|
||||||
interator2 = each[interator:interator + 3]
|
# interator2 = each[interator:interator + 3]
|
||||||
result = each.split(interator2, 1)[0] + interator2
|
# result = each.split(interator2, 1)[0] + interator2
|
||||||
players.append(result.rstrip())
|
# players.append(result.rstrip())
|
||||||
|
|
||||||
event['golf_standings'] = players
|
# event['golf_standings'] = players
|
||||||
|
|
||||||
|
|
||||||
elif (league == 'LIV'):
|
elif (league == 'LIV'):
|
||||||
event['golf_standings'] = d['strResult']
|
# event['golf_standings'] = d['strResult']
|
||||||
event['golf_rankings'] = d['player_results']
|
event['golf_rankings'] = d['player_results']
|
||||||
|
for player in event['golf_rankings']:
|
||||||
|
try:
|
||||||
|
if player['country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
|
||||||
|
urllib.request.urlretrieve(player['country'], 'logos/ufc_countries/' + player['country'].split('/')[-1].split('&')[0])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# rank = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'T1', 'T2', 'T3', 'T4', 'T5',
|
||||||
|
# 'T6', 'T7', 'T8', 'T9', 'T10']
|
||||||
|
# def convert(string):
|
||||||
|
# string = repr(string).replace('/', '')
|
||||||
|
# li = list(string.split('\\'))
|
||||||
|
# return li
|
||||||
|
|
||||||
rank = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'T1', 'T2', 'T3', 'T4', 'T5',
|
# try:
|
||||||
'T6', 'T7', 'T8', 'T9', 'T10']
|
# str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
||||||
|
# strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
def convert(string):
|
# players = []
|
||||||
string = repr(string).replace('/', '')
|
# teams = []
|
||||||
li = list(string.split('\\'))
|
|
||||||
return li
|
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
# for each in str3:
|
||||||
strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
# each = each.replace('nT', 'T', 1)
|
||||||
except:
|
# if each[:2] in rank:
|
||||||
pass
|
# try:
|
||||||
|
# first_space = each.find(' ', 1)
|
||||||
|
# second_space = each.find(' ', 4)
|
||||||
|
# first_name = each[first_space:second_space].lstrip()
|
||||||
|
# initial = first_name[0] + '.'
|
||||||
|
# each = each.replace(first_name,initial)
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
# interator = each.find('-')
|
||||||
|
# if interator < 0:
|
||||||
|
# interator = 0
|
||||||
|
# interator2 = each[interator:interator + 3]
|
||||||
|
# result = each.split(interator2, 1)[0] + interator2
|
||||||
|
# players.append(result.rstrip())
|
||||||
|
|
||||||
players = []
|
# for each in strTeams:
|
||||||
teams = []
|
# each = each.replace('nT', 'T', 1)
|
||||||
|
# if each[:2] in rank:
|
||||||
try:
|
# each = each.split('GC')
|
||||||
for each in str3:
|
# score = each[1].rfind(' ')
|
||||||
each = each.replace('nT', 'T', 1)
|
# score2 = each[1][score:score+4]
|
||||||
if each[:2] in rank:
|
# each2 = each[0] + score2
|
||||||
try:
|
# teams.append(each2)
|
||||||
first_space = each.find(' ', 1)
|
# except:
|
||||||
second_space = each.find(' ', 4)
|
# pass
|
||||||
first_name = each[first_space:second_space].lstrip()
|
|
||||||
initial = first_name[0] + '.'
|
|
||||||
each = each.replace(first_name,initial)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
interator = each.find('-')
|
|
||||||
if interator < 0:
|
|
||||||
interator = 0
|
|
||||||
interator2 = each[interator:interator + 3]
|
|
||||||
result = each.split(interator2, 1)[0] + interator2
|
|
||||||
players.append(result.rstrip())
|
|
||||||
|
|
||||||
for each in strTeams:
|
|
||||||
each = each.replace('nT', 'T', 1)
|
|
||||||
if each[:2] in rank:
|
|
||||||
each = each.split('GC')
|
|
||||||
score = each[1].rfind(' ')
|
|
||||||
score2 = each[1][score:score+4]
|
|
||||||
each2 = each[0] + score2
|
|
||||||
teams.append(each2)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
event['golf_standings'] = [players] + [teams]
|
|
||||||
|
|
||||||
|
# event['golf_standings'] = [players] + [teams]
|
||||||
else:
|
else:
|
||||||
event['away_score'] = d['intAwayScore']
|
event['away_score'] = d['intAwayScore']
|
||||||
event['home_score'] = d['intHomeScore']
|
event['home_score'] = d['intHomeScore']
|
||||||
|
|
||||||
events.append(event)
|
events.append(event)
|
||||||
leagues_info[league.upper()] = events
|
leagues_info[league.upper()] = events
|
||||||
all_settings['leagues'] = leagues_info
|
all_settings['leagues'] = leagues_info
|
||||||
|
Loading…
Reference in New Issue
Block a user