replaced old golf data with new espn golf data
This commit is contained in:
parent
5c042c9c09
commit
4669a28d85
@ -1085,96 +1085,103 @@ 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']
|
||||
|
||||
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
|
||||
|
||||
str3 = convert(event['golf_standings'])
|
||||
|
||||
players = []
|
||||
|
||||
|
||||
for each in str3:
|
||||
each = each.replace('nT', 'T', 1)
|
||||
if each[:2] in rank:
|
||||
for player in event['golf_rankings']:
|
||||
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)
|
||||
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
|
||||
interator = each.find('-')
|
||||
if interator < 0:
|
||||
interator = 0
|
||||
interator2 = each[interator:interator + 3]
|
||||
result = each.split(interator2, 1)[0] + interator2
|
||||
players.append(result.rstrip())
|
||||
# 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
|
||||
|
||||
event['golf_standings'] = players
|
||||
# str3 = convert(event['golf_standings'])
|
||||
|
||||
# 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())
|
||||
|
||||
# event['golf_standings'] = players
|
||||
|
||||
|
||||
elif (league == 'LIV'):
|
||||
event['golf_standings'] = d['strResult']
|
||||
# event['golf_standings'] = d['strResult']
|
||||
event['golf_rankings'] = d['player_results']
|
||||
|
||||
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
|
||||
|
||||
for player in event['golf_rankings']:
|
||||
try:
|
||||
str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
||||
strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
||||
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
|
||||
|
||||
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 = []
|
||||
|
||||
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
|
||||
# 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())
|
||||
|
||||
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']
|
||||
|
Loading…
Reference in New Issue
Block a user