added ufc

This commit is contained in:
Justin 2023-04-17 17:55:53 +08:00 committed by GitHub
parent 5e7e332bbc
commit 78b745b884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -911,86 +911,49 @@ def updateLeagueEvents(api_key, time, logf):
ten_or_fifteen = slice(3)
else:
ten_or_fifteen = slice(None)
for d in all_data[league][ten_or_fifteen]:
event = {}
event['date'] = d['dateEvent']
if time == 'live':
event['progess'] = d['strProgress']
event['status'] = d['strStatus']
else:
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU') or (league == 'LIV') or (league == 'F1') or (league == 'NASCAR'):
event['date'] = d['dateEvent']
event['event'] = d['strEvent'].replace("\u2019","'")
event['venue'] = d['strVenue'].replace("\u2019","'")
event['city'] = d['strCity'].replace("\u2019","'")
event['country'] = d['strCountry']
event['season'] = d['strSeason']
if league == 'UFC':
event = all_data['UFC'][0]
events.append(event)
else:
for d in all_data[league][ten_or_fifteen]:
event = {}
event['date'] = d['dateEvent']
if time == 'live':
event['progess'] = d['strProgress']
event['status'] = d['strStatus']
else:
event['round'] = d['intRound']
event['time'] = d['strTime']
event['home_team'] = d['strHomeTeam']
event['away_team'] = d['strAwayTeam']
if time != 'upcoming':
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
event['golf_standings'] = d['strResult']
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU') or (league == 'LIV') or (league == 'F1') or (league == 'NASCAR'):
event['date'] = d['dateEvent']
event['event'] = d['strEvent'].replace("\u2019","'")
event['venue'] = d['strVenue'].replace("\u2019","'")
event['city'] = d['strCity'].replace("\u2019","'")
event['country'] = d['strCountry']
event['season'] = d['strSeason']
else:
event['round'] = d['intRound']
event['time'] = d['strTime']
event['home_team'] = d['strHomeTeam']
event['away_team'] = d['strAwayTeam']
if time != 'upcoming':
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
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']
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
def convert(string):
string = repr(string).replace('/', '')
li = list(string.split('\\'))
return li
str3 = convert(event['golf_standings'])
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())
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:
@ -1009,24 +972,66 @@ def updateLeagueEvents(api_key, time, logf):
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
event['golf_standings'] = [players] + [teams]
else:
event['away_score'] = d['intAwayScore']
event['home_score'] = d['intHomeScore']
events.append(event)
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+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