fixed not able to display multiple upcoming + past sports

This commit is contained in:
Justin 2022-03-04 23:09:58 +08:00 committed by GitHub
parent b6d1e290c8
commit 9fa50f1d8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1591,35 +1591,35 @@ class StockTicker():
buff_size = 25
for match in league_info:
home_team = match['home_team']
away_team = match['away_team']
strHomeTeam = match['strHomeTeam']
strAwayTeam = match['strAwayTeam']
if time != 'future':
home_score = str(match['home_score'])
away_score = str(match['away_score'])
intHomeScore = str(match['intHomeScore'])
intAwayScore = str(match['intAwayScore'])
date = match['date'].replace('-', '.')
dateEvent = match['dateEvent'].replace('-', '.')
#rond = match['round']
try:
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[home_team]['logo']))
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strHomeTeam]['logo']))
except Exception as e:
home_logo = self.textImage(home_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
home_logo = self.textImage(strHomeTeam.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
try:
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[away_team]['logo']))
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
except Exception as e:
away_logo = self.textImage(away_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
away_logo = self.textImage(strAwayTeam.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
date_timage = self.textImage(date, small_font, r = 255, g = 255, b = 255)
date_timage = self.textImage(dateEvent, small_font, r = 255, g = 255, b = 255)
img.paste(home_logo, (x_offset,0))
@ -1630,12 +1630,12 @@ class StockTicker():
img.paste(date_timage, (x_offset+5, 0))
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
h_colour = mcolors.to_rgb(sports_info[strHomeTeam]['colour'].replace(' ', ''))
a_colour = mcolors.to_rgb(sports_info[strAwayTeam]['colour'].replace(' ', ''))
hc_timage = self.textImage(sports_info[home_team]['code'], med_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
ac_timage = self.textImage(sports_info[away_team]['code'], med_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
hc_timage = self.textImage(sports_info[strHomeTeam]['code'], med_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
ac_timage = self.textImage(sports_info[strAwayTeam]['code'], med_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
vs_timage = self.textImage('vs', med_font, r = 255, g = 255, b = 255, h_buff = 5)
img.paste(hc_timage, (x_offset, 9))
@ -1644,15 +1644,15 @@ class StockTicker():
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
else:
score_image = self.textImage(home_score + '-' + away_score, large_font, h_buff = 5, r = 255, g = 255, b = 255)
score_image = self.textImage(intHomeScore + '-' + intAwayScore, large_font, h_buff = 5, r = 255, g = 255, b = 255)
#vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
h_colour = mcolors.to_rgb(sports_info[strHomeTeam]['colour'].replace(' ', ''))
a_colour = mcolors.to_rgb(sports_info[strAwayTeam]['colour'].replace(' ', ''))
hc_timage = self.textImage(sports_info[home_team]['code'], small_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
ac_timage = self.textImage(sports_info[away_team]['code'], small_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
hc_timage = self.textImage(sports_info[strHomeTeam]['code'], small_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
ac_timage = self.textImage(sports_info[strAwayTeam]['code'], small_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
vs_timage = self.textImage('vs', small_font, r = 255, g = 255, b = 255)
if date_timage.size[0] > score_image.size[0]: