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['purse'] = d['purse']
|
||||
except:
|
||||
pass
|
||||
pass
|
||||
event['event'] = d['strEvent'].replace("\u2019","'")
|
||||
event['venue'] = d['strVenue'].replace("\u2019","'")
|
||||
event['city'] = d['strCity'].replace("\u2019","'")
|
||||
@ -1085,100 +1085,107 @@ def updateLeagueEvents(api_key, time, logf):
|
||||
|
||||
if time != 'upcoming':
|
||||
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']
|
||||
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',
|
||||
'T6', 'T7', 'T8', 'T9', 'T10']
|
||||
# str3 = convert(event['golf_standings'])
|
||||
|
||||
def convert(string):
|
||||
string = repr(string).replace('/', '')
|
||||
li = list(string.split('\\'))
|
||||
return li
|
||||
|
||||
str3 = convert(event['golf_standings'])
|
||||
|
||||
players = []
|
||||
# players = []
|
||||
|
||||
|
||||
for each in str3:
|
||||
each = each.replace('nT', 'T', 1)
|
||||
if each[:2] in rank:
|
||||
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())
|
||||
# for each in str3:
|
||||
# each = each.replace('nT', 'T', 1)
|
||||
# if each[:2] in rank:
|
||||
# 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())
|
||||
|
||||
event['golf_standings'] = players
|
||||
# event['golf_standings'] = players
|
||||
|
||||
|
||||
elif (league == 'LIV'):
|
||||
event['golf_standings'] = d['strResult']
|
||||
# event['golf_standings'] = d['strResult']
|
||||
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',
|
||||
'T6', 'T7', 'T8', 'T9', 'T10']
|
||||
# try:
|
||||
# str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
||||
# strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
||||
# except:
|
||||
# pass
|
||||
|
||||
def convert(string):
|
||||
string = repr(string).replace('/', '')
|
||||
li = list(string.split('\\'))
|
||||
return li
|
||||
# players = []
|
||||
# teams = []
|
||||
|
||||
try:
|
||||
str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
||||
strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
||||
except:
|
||||
pass
|
||||
# try:
|
||||
# for each in str3:
|
||||
# each = each.replace('nT', 'T', 1)
|
||||
# if each[:2] in rank:
|
||||
# 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 = []
|
||||
teams = []
|
||||
|
||||
try:
|
||||
for each in str3:
|
||||
each = each.replace('nT', 'T', 1)
|
||||
if each[:2] in rank:
|
||||
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())
|
||||
|
||||
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]
|
||||
# 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]
|
||||
else:
|
||||
event['away_score'] = d['intAwayScore']
|
||||
event['home_score'] = d['intHomeScore']
|
||||
|
||||
|
||||
events.append(event)
|
||||
leagues_info[league.upper()] = events
|
||||
all_settings['leagues'] = leagues_info
|
||||
|
Loading…
Reference in New Issue
Block a user