This commit is contained in:
Justin 2023-03-23 16:30:58 +08:00 committed by GitHub
parent fb91c87a4d
commit 02daa21adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -845,7 +845,7 @@ def updateLeagueEvents(api_key, time, logf):
for league in all_data.keys(): for league in all_data.keys():
ten_or_fifteen = slice(None) ten_or_fifteen = slice(None)
events = [] events = []
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'): if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU') or (league == 'LIV'):
ten_or_fifteen = slice(3) ten_or_fifteen = slice(3)
else: else:
ten_or_fifteen = slice(None) ten_or_fifteen = slice(None)
@ -857,7 +857,7 @@ def updateLeagueEvents(api_key, time, logf):
event['progess'] = d['strProgress'] event['progess'] = d['strProgress']
event['status'] = d['strStatus'] event['status'] = d['strStatus']
else: else:
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'): if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU') or (league == 'LIV'):
event['date'] = d['dateEvent'] event['date'] = d['dateEvent']
event['event'] = d['strEvent'].replace("\u2019","'") event['event'] = d['strEvent'].replace("\u2019","'")
event['venue'] = d['strVenue'].replace("\u2019","'") event['venue'] = d['strVenue'].replace("\u2019","'")
@ -906,6 +906,60 @@ def updateLeagueEvents(api_key, time, logf):
players.append(result.rstrip()) players.append(result.rstrip())
event['golf_standings'] = players event['golf_standings'] = players
elif (league == 'LIV'):
event['golf_standings'] = d['strResult']
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:
str3 = convert(event['golf_standings'].split('--------------------------------------')[0])
strTeams = convert(event['golf_standings'].split('--------------------------------------')[1])
except:
pass
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+3]
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']
@ -919,15 +973,7 @@ def updateLeagueEvents(api_key, time, logf):
f.close() f.close()
except: except:
pass pass
#logf = open('log.txt', "a")
#exc_type, exc_obj, exc_tb = sys.exc_info()
#fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
#logf.write(str(e))
#logf.write('. file: ' + fname)
#logf.write('. line: ' + str(exc_tb.tb_lineno))
#logf.write('. type: ' + str(exc_type))
#logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
#logf.close()
def updateSports(api_key, logf): def updateSports(api_key, logf):