don't show upcoming games when live (prof)

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

View File

@ -3797,117 +3797,116 @@ class StockTicker():
x_offset += next_match.size[0]
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'])
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']))
width1, height1 = home_logo.size
home_logo1 = home_logo.resize((int(width1/2), int(height1/2)))
except Exception as e:
home_logo1 = self.textImage(strHomeTeam, small_font, r = 255, g = 255, b = 255)
try:
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strHomeTeam]['logo']))
width1, height1 = home_logo.size
home_logo1 = home_logo.resize((int(width1/2), int(height1/2)))
except Exception as e:
home_logo1 = self.textImage(strHomeTeam, small_font, r = 255, g = 255, b = 255)
try:
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
width2, height2 = away_logo.size
away_logo1 = away_logo.resize((int(width2/2), int(height2/2)))
except Exception as e:
away_logo1 = self.textImage(strAwayTeam, small_font, r = 255, g = 255, b = 255)
try:
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
width2, height2 = away_logo.size
away_logo1 = away_logo.resize((int(width2/2), int(height2/2)))
except Exception as e:
away_logo1 = self.textImage(strAwayTeam, small_font, r = 255, g = 255, b = 255)
error = False
error = False
img.paste(away_logo1, (x_offset,0))
x_offset += (away_logo1.size[0] + 2)
img.paste(away_logo1, (x_offset,0))
x_offset += (away_logo1.size[0] + 2)
score_image = self.textImage(intAwayScore + '-' + intHomeScore, font, h_buff = 5, r = 255, g = 255, b = 255)
score_image = self.textImage(intAwayScore + '-' + intHomeScore, 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'], font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
except:
hc_timage = self.textImage('.', small_font, r = 255, g = 255, b = 255)
error = True
try:
ac_timage = self.textImage(sports_info[strAwayTeam]['code'], font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
except:
ac_timage = self.textImage('.', small_font, r = 255, g = 255, b = 255)
error = True
if date_timage.size[0] > (hc_timage.size[0] + 2 + score_image.size[0] + ac_timage.size[0]):
x_offset10 = x_offset + int((date_timage.size[0]/2)-(score_image.size[0]/2)-ac_timage.size[0])
img.paste(date_timage,(x_offset, 0))
img.paste(score_image, (x_offset + int((date_timage.size[0]/2)-(score_image.size[0]/2)), 5))
x_offset += date_timage.size[0]
img.paste(ac_timage,(x_offset10, 5))
if match['isLive'] == 'post':
if int(intHomeScore) < int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
ua_image = Image.new("RGB", (ac_timage.size[0] -3, 1))
ua_image1 = ImageDraw.Draw(ua_image)
ua_image1.line((0,0,ac_timage.size[0]-3,0), fill="red", width = 0)
img.paste(ua_image, (x_offset10, ac_timage.size[1]+4))
x_offset10 += ac_timage.size[0] + score_image.size[0]
img.paste(hc_timage,(x_offset10, 5))
if match['isLive'] == 'post':
if int(intHomeScore) > int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
u_image = Image.new("RGB", (hc_timage.size[0] -3, 1))
u_image1 = ImageDraw.Draw(u_image)
u_image1.line((0,0,hc_timage.size[0]-3,0), fill="red", width = 0)
img.paste(u_image, (x_offset10, hc_timage.size[1]+4))
x_offset10 += hc_timage.size[0]
if error:
img.paste(home_logo1, (max(x_offset + date_timage.size[0], x_offset10),0))
x_offset += (home_logo1.size[0] + date_timage.size[0])
else:
img.paste(home_logo1, (max(x_offset,x_offset10),0))
x_offset += home_logo1.size[0]
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'], font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
except:
hc_timage = self.textImage('.', small_font, r = 255, g = 255, b = 255)
error = True
try:
ac_timage = self.textImage(sports_info[strAwayTeam]['code'], font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
except:
ac_timage = self.textImage('.', small_font, r = 255, g = 255, b = 255)
error = True
if date_timage.size[0] > (hc_timage.size[0] + 2 + score_image.size[0] + ac_timage.size[0]):
x_offset10 = x_offset + int((date_timage.size[0]/2)-(score_image.size[0]/2)-ac_timage.size[0])
img.paste(date_timage,(x_offset, 0))
img.paste(score_image, (x_offset + int((date_timage.size[0]/2)-(score_image.size[0]/2)), 5))
x_offset += date_timage.size[0]
img.paste(ac_timage,(x_offset10, 5))
if match['isLive'] == 'post':
if int(intHomeScore) < int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
ua_image = Image.new("RGB", (ac_timage.size[0] -3, 1))
ua_image1 = ImageDraw.Draw(ua_image)
ua_image1.line((0,0,ac_timage.size[0]-3,0), fill="red", width = 0)
img.paste(ua_image, (x_offset10, ac_timage.size[1]+4))
x_offset10 += ac_timage.size[0] + score_image.size[0]
img.paste(hc_timage,(x_offset10, 5))
if match['isLive'] == 'post':
if int(intHomeScore) > int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
u_image = Image.new("RGB", (hc_timage.size[0] -3, 1))
u_image1 = ImageDraw.Draw(u_image)
u_image1.line((0,0,hc_timage.size[0]-3,0), fill="red", width = 0)
img.paste(u_image, (x_offset10, hc_timage.size[1]+4))
x_offset10 += hc_timage.size[0]
if error:
img.paste(home_logo1, (max(x_offset + date_timage.size[0], x_offset10),0))
x_offset += (home_logo1.size[0] + date_timage.size[0])
else:
img.paste(home_logo1, (max(x_offset,x_offset10),0))
x_offset += home_logo1.size[0]
x_offset_date = (x_offset + ac_timage.size[0] + int(score_image.size[0]/2) - int(date_timage.size[0]/2))
img.paste(date_timage, (x_offset_date,0))
#img.paste(date_timage, (x_offset+20+int((score_image.size[0] - date_timage.size[0])/2),0))
img.paste(ac_timage, (x_offset, 5))
else:
x_offset_date = (x_offset + ac_timage.size[0] + int(score_image.size[0]/2) - int(date_timage.size[0]/2))
img.paste(date_timage, (x_offset_date,0))
#img.paste(date_timage, (x_offset+20+int((score_image.size[0] - date_timage.size[0])/2),0))
img.paste(ac_timage, (x_offset, 5))
if match['isLive'] == 'post':
if int(intHomeScore) < int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
ua_image = Image.new("RGB", (ac_timage.size[0] -3, 1))
ua_image1 = ImageDraw.Draw(ua_image)
ua_image1.line((0,0,ac_timage.size[0]-3,0), fill="red", width = 0)
img.paste(ua_image, (x_offset, ac_timage.size[1]+4))
x_offset += ac_timage.size[0]
img.paste(score_image, (x_offset, 5))
x_offset += score_image.size[0]
img.paste(hc_timage, (x_offset, 5))
if match['isLive'] == 'post':
if int(intHomeScore) > int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
u_image = Image.new("RGB", (hc_timage.size[0] -3, 1))
u_image1 = ImageDraw.Draw(u_image)
u_image1.line((0,0,hc_timage.size[0]-3,0), fill="red", width = 0)
img.paste(u_image, (x_offset, hc_timage.size[1]+4))
x_offset += hc_timage.size[0]
x_offset_date += date_timage.size[0]
if error:
img.paste(home_logo1, (max(x_offset + date_timage.size[0], x_offset_date),0))
x_offset += (home_logo1.size[0] + date_timage.size[0])
else:
img.paste(home_logo1, (max(x_offset,x_offset_date),0))
x_offset += home_logo1.size[0]
x_offset += buff_size
if match['isLive'] == 'post':
if int(intHomeScore) < int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
ua_image = Image.new("RGB", (ac_timage.size[0] -3, 1))
ua_image1 = ImageDraw.Draw(ua_image)
ua_image1.line((0,0,ac_timage.size[0]-3,0), fill="red", width = 0)
img.paste(ua_image, (x_offset, ac_timage.size[1]+4))
x_offset += ac_timage.size[0]
img.paste(score_image, (x_offset, 5))
x_offset += score_image.size[0]
img.paste(hc_timage, (x_offset, 5))
if match['isLive'] == 'post':
if int(intHomeScore) > int(intAwayScore) or int(intHomeScore) == int(intAwayScore):
u_image = Image.new("RGB", (hc_timage.size[0] -3, 1))
u_image1 = ImageDraw.Draw(u_image)
u_image1.line((0,0,hc_timage.size[0]-3,0), fill="red", width = 0)
img.paste(u_image, (x_offset, hc_timage.size[1]+4))
x_offset += hc_timage.size[0]
x_offset_date += date_timage.size[0]
if error:
img.paste(home_logo1, (max(x_offset + date_timage.size[0], x_offset_date),0))
x_offset += (home_logo1.size[0] + date_timage.size[0])
else:
img.paste(home_logo1, (max(x_offset,x_offset_date),0))
x_offset += home_logo1.size[0]
x_offset += buff_size
x_offset += 20
img = img.crop((0,0,x_offset ,16))
imgs.append(img)