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 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']:
|
||||||
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:
|
|
||||||
try:
|
try:
|
||||||
first_space = each.find(' ', 1)
|
if player['country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
|
||||||
second_space = each.find(' ', 4)
|
urllib.request.urlretrieve(player['country'], 'logos/ufc_countries/' + player['country'].split('/')[-1].split('&')[0])
|
||||||
first_name = each[first_space:second_space].lstrip()
|
|
||||||
initial = first_name[0] + '.'
|
|
||||||
each = each.replace(first_name,initial)
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
interator = each.find('-')
|
# rank = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'T1', 'T2', 'T3', 'T4', 'T5',
|
||||||
if interator < 0:
|
# 'T6', 'T7', 'T8', 'T9', 'T10']
|
||||||
interator = 0
|
# def convert(string):
|
||||||
interator2 = each[interator:interator + 3]
|
# string = repr(string).replace('/', '')
|
||||||
result = each.split(interator2, 1)[0] + interator2
|
# li = list(string.split('\\'))
|
||||||
players.append(result.rstrip())
|
# 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'):
|
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']:
|
||||||
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
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
if player['country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
|
||||||
strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
urllib.request.urlretrieve(player['country'], 'logos/ufc_countries/' + player['country'].split('/')[-1].split('&')[0])
|
||||||
except:
|
except:
|
||||||
pass
|
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 = []
|
# try:
|
||||||
teams = []
|
# str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
|
||||||
|
# strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
try:
|
# players = []
|
||||||
for each in str3:
|
# teams = []
|
||||||
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:
|
# try:
|
||||||
each = each.replace('nT', 'T', 1)
|
# for each in str3:
|
||||||
if each[:2] in rank:
|
# each = each.replace('nT', 'T', 1)
|
||||||
each = each.split('GC')
|
# if each[:2] in rank:
|
||||||
score = each[1].rfind(' ')
|
# try:
|
||||||
score2 = each[1][score:score+4]
|
# first_space = each.find(' ', 1)
|
||||||
each2 = each[0] + score2
|
# second_space = each.find(' ', 4)
|
||||||
teams.append(each2)
|
# first_name = each[first_space:second_space].lstrip()
|
||||||
except:
|
# initial = first_name[0] + '.'
|
||||||
pass
|
# 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:
|
else:
|
||||||
event['away_score'] = d['intAwayScore']
|
event['away_score'] = d['intAwayScore']
|
||||||
event['home_score'] = d['intHomeScore']
|
event['home_score'] = d['intHomeScore']
|
||||||
|
Loading…
Reference in New Issue
Block a user