don't show upcoming games when live

This commit is contained in:
Justin 2023-05-23 18:22:27 +08:00 committed by GitHub
parent 29a7e3c334
commit ee441dfd1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2663,75 +2663,74 @@ class StockTicker():
else:
for match in league_info:
if match['time'] != 'Scheduled':
dateEvent = match['time']
date_timage = self.textImage(dateEvent, small_font, r=255, g=255, b=255)
dateEvent = match['time']
date_timage = self.textImage(dateEvent, small_font, r=255, g=255, b=255)
strHomeTeam = match['home_team']
strAwayTeam = match['away_team']
intHomeScore = str(match['home_score'])
intAwayScore = str(match['away_score'])
try:
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strHomeTeam]['logo']))
except Exception as e:
home_logo = self.textImage(strHomeTeam.replace(' ', '\n'), extra_small_font, r = 255, g = 255, b = 255)
try:
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
except Exception as e:
away_logo = self.textImage(strAwayTeam.replace(' ', '\n'), extra_small_font, r = 255, g = 255, b = 255)
img.paste(away_logo, (x_offset,0))
x_offset += away_logo.size[0] + 4
score_image = self.textImage(intAwayScore + '-' + intHomeScore, large_font, h_buff = 5, r = 255, g = 255, b = 255)
strHomeTeam = match['home_team']
strAwayTeam = match['away_team']
intHomeScore = str(match['home_score'])
intAwayScore = str(match['away_score'])
try:
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strHomeTeam]['logo']))
except Exception as e:
home_logo = self.textImage(strHomeTeam.replace(' ', '\n'), extra_small_font, r = 255, g = 255, b = 255)
try:
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
except Exception as e:
away_logo = self.textImage(strAwayTeam.replace(' ', '\n'), extra_small_font, r = 255, g = 255, b = 255)
img.paste(away_logo, (x_offset,0))
x_offset += away_logo.size[0] + 4
score_image = self.textImage(intAwayScore + '-' + intHomeScore, large_font, h_buff = 5, r = 255, g = 255, b = 255)
try:
h_colour = mcolors.to_rgb(sports_info[strHomeTeam]['colour'].replace(' ', ''))
except:
pass
try:
a_colour = mcolors.to_rgb(sports_info[strAwayTeam]['colour'].replace(' ', ''))
except:
pass
try:
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))
except Exception as e:
hc_timage = self.textImage('.', extra_small_font, r = 255, g = 255, b = 255)
try:
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))
except Exception as e:
ac_timage = self.textImage('.', extra_small_font, r = 255, g = 255, b = 255)
try:
h_colour = mcolors.to_rgb(sports_info[strHomeTeam]['colour'].replace(' ', ''))
except:
pass
try:
a_colour = mcolors.to_rgb(sports_info[strAwayTeam]['colour'].replace(' ', ''))
except:
pass
try:
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))
except Exception as e:
hc_timage = self.textImage('.', extra_small_font, r = 255, g = 255, b = 255)
try:
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))
except Exception as e:
ac_timage = self.textImage('.', extra_small_font, r = 255, g = 255, b = 255)
vs_timage = self.textImage('VS', extra_small_font, r = 255, g = 255, b = 255)
vs_size = hc_timage.size[0] + ac_timage.size[0] + vs_timage.size[0]
vs_timage = self.textImage('VS', extra_small_font, r = 255, g = 255, b = 255)
vs_size = hc_timage.size[0] + ac_timage.size[0] + vs_timage.size[0]
main_offset = x_offset + int(max(vs_size, date_timage.size[0], score_image.size[0])/2)
img.paste(date_timage,(main_offset - int(date_timage.size[0]/2),0))
img.paste(vs_timage, (main_offset - int(vs_timage.size[0]/2),10))
img.paste(ac_timage, (main_offset - int(vs_timage.size[0]/2) - ac_timage.size[0], 9))
img.paste(score_image, (main_offset - int(score_image.size[0]/2), 15))
if match['isLive'] == 'post':
if int(intHomeScore) < int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
ua_image = Image.new("RGB", (hc_timage.size[0] -2, 1))
ua_image1 = ImageDraw.Draw(ua_image)
ua_image1.line((0,0,hc_timage.size[0]-2,0), fill="red", width = 0)
img.paste(ua_image, (main_offset - int(vs_timage.size[0]/2)-ac_timage.size[0], ac_timage.size[1]+7))
img.paste(hc_timage, (main_offset + int(vs_timage.size[0]/2),9))
if match['isLive'] == 'post':
if int(intHomeScore) > int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
u_image = Image.new("RGB", (ac_timage.size[0] -2, 1))
u_image1 = ImageDraw.Draw(u_image)
u_image1.line((0,0,ac_timage.size[0]-2,0), fill="red", width = 0)
img.paste(u_image, (main_offset + int(vs_timage.size[0]/2), hc_timage.size[1]+7))
x_offset = (main_offset + max(int(date_timage.size[0]/2), int(vs_timage.size[0]/2) + hc_timage.size[0], int(score_image.size[0]/2)) + 4)
img.paste(home_logo, (x_offset,0))
x_offset += home_logo.size[0] + buff_size
main_offset = x_offset + int(max(vs_size, date_timage.size[0], score_image.size[0])/2)
img.paste(date_timage,(main_offset - int(date_timage.size[0]/2),0))
img.paste(vs_timage, (main_offset - int(vs_timage.size[0]/2),10))
img.paste(ac_timage, (main_offset - int(vs_timage.size[0]/2) - ac_timage.size[0], 9))
img.paste(score_image, (main_offset - int(score_image.size[0]/2), 15))
if match['isLive'] == 'post':
if int(intHomeScore) < int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
ua_image = Image.new("RGB", (hc_timage.size[0] -2, 1))
ua_image1 = ImageDraw.Draw(ua_image)
ua_image1.line((0,0,hc_timage.size[0]-2,0), fill="red", width = 0)
img.paste(ua_image, (main_offset - int(vs_timage.size[0]/2)-ac_timage.size[0], ac_timage.size[1]+7))
img.paste(hc_timage, (main_offset + int(vs_timage.size[0]/2),9))
if match['isLive'] == 'post':
if int(intHomeScore) > int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
u_image = Image.new("RGB", (ac_timage.size[0] -2, 1))
u_image1 = ImageDraw.Draw(u_image)
u_image1.line((0,0,ac_timage.size[0]-2,0), fill="red", width = 0)
img.paste(u_image, (main_offset + int(vs_timage.size[0]/2), hc_timage.size[1]+7))
x_offset = (main_offset + max(int(date_timage.size[0]/2), int(vs_timage.size[0]/2) + hc_timage.size[0], int(score_image.size[0]/2)) + 4)
img.paste(home_logo, (x_offset,0))
x_offset += home_logo.size[0] + buff_size
img = img.crop((0,0,x_offset,32))
imgs.append(img)
except Exception as e: