added live sports
This commit is contained in:
parent
dae81b2626
commit
b3b5e5b842
790
stockTicker.py
790
stockTicker.py
@ -74,7 +74,7 @@ class StockTicker():
|
||||
'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional,
|
||||
'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional,
|
||||
'Daily Forecast Prof':self.getDailyWeatherProfessional, 'Sports (Team Stats) Prof':lambda : self.getLeagueTableProfessional('NHL'), 'Sports (Upcoming Games) Prof': lambda : self.getLeagueProfessional('NHL', 'future'),
|
||||
'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional, 'Custom Images Prof': self.getUserImagesProfessional, 'Movies Prof': self.getMoviesProfessional}
|
||||
'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional, 'Custom Images Prof': self.getUserImagesProfessional, 'Movies Prof': self.getMoviesProfessional, 'Sports (Live Games) Prof': lambda : self.getLeagueProfessional('NBA', 'live')}
|
||||
|
||||
self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json',
|
||||
'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json',
|
||||
@ -83,7 +83,7 @@ class StockTicker():
|
||||
'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json',
|
||||
'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json',
|
||||
'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json', 'Commodities Prof':'csv/commodities_settings.json', 'Indices Prof': 'csv/indices_settings.json',
|
||||
'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json', 'Custom Images Prof': 'csv/image_settings.json', 'Movies Prof': 'csv/movie_settings.json'}
|
||||
'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json', 'Custom Images Prof': 'csv/image_settings.json', 'Movies Prof': 'csv/movie_settings.json', 'Sports (Live Games) Prof': 'csv/live_games.json'}
|
||||
|
||||
|
||||
def openImage(self, image_file):
|
||||
@ -2000,6 +2000,7 @@ class StockTicker():
|
||||
|
||||
return news_image
|
||||
|
||||
|
||||
def getLeagueImage(self, league=False, time = 'past'):
|
||||
|
||||
if time in ['past', 'live']:
|
||||
@ -2162,6 +2163,421 @@ class StockTicker():
|
||||
|
||||
return self.stitchImage(imgs)
|
||||
|
||||
|
||||
def getLeagueImage(self, league=False, time = 'past'):
|
||||
|
||||
if time in ['past', 'live']:
|
||||
filepath = 'csv/{}_games.json'.format(time)
|
||||
else:
|
||||
filepath = 'csv/upcoming_games.json'
|
||||
|
||||
f = open(filepath, 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
title_img = self.openImage('feature_titles/sports_'+ time + '.png')
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/sports_{}.png'.format(time))
|
||||
imgs = [title_img, self.blank]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
leagues_info = all_settings['leagues']
|
||||
leagues = list(leagues_info.keys())
|
||||
|
||||
|
||||
if time == 'live':
|
||||
for league in leagues:
|
||||
try:
|
||||
x_offset = 0
|
||||
if league == 'NFL':
|
||||
f = open('csv/live_nfl.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['NFL'][0]
|
||||
elif league == 'NHL':
|
||||
f = open('csv/live_nhl.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['NHL'][0]
|
||||
elif league == 'NBA':
|
||||
f = open('csv/live_nba.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['NBA'][0]
|
||||
elif league == 'MLB':
|
||||
f = open('csv/live_mlb.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['MLB'][0]
|
||||
elif league == 'MLS':
|
||||
f = open('csv/live_mls.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['MLS'][0]
|
||||
elif league == 'PREMIERLEAGUE':
|
||||
f = open('csv/live_pl.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['PREMIERLEAGUE'][0]
|
||||
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
|
||||
try:
|
||||
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
|
||||
img.paste(league_logo, (x_offset,0))
|
||||
x_offset += league_logo.size[0] +self.blank.size[0]
|
||||
except:
|
||||
pass
|
||||
|
||||
slight_large_font = ImageFont.load("./fonts/9x15.pil")
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
med_font = ImageFont.load("./fonts/7x14B.pil")
|
||||
large_font = ImageFont.load("./fonts/9x18B.pil")
|
||||
extra_small_font = ImageFont.load("./fonts/4x6.pil")
|
||||
|
||||
try:
|
||||
sports_info = self.readSportsCSV(league)
|
||||
except:
|
||||
pass
|
||||
|
||||
buff_size = 25
|
||||
|
||||
if all_settings['leagues'][league][2] == 'no_live' and all_settings['leagues'][league][3] == 'no_upcoming':
|
||||
no_match = self.textImage(('No live games').upper(), slight_large_font, r = 255, g = 255 , b = 255)
|
||||
img.paste(no_match, (x_offset,10))
|
||||
x_offset += no_match.size[0] + buff_size
|
||||
|
||||
elif all_settings['leagues'][league][3] != 'no_upcoming':
|
||||
next_match = self.textImage('Next game: ' + all_settings['leagues'][league][3], slight_large_font, r=255,g=255,b=255)
|
||||
img.paste(next_match, (x_offset,10))
|
||||
x_offset += next_match.size[0] + buff_size
|
||||
|
||||
else:
|
||||
for match in league_info:
|
||||
|
||||
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(home_logo, (x_offset,0))
|
||||
|
||||
x_offset += home_logo.size[0] + 4
|
||||
|
||||
score_image = self.textImage(intHomeScore + '-' + intAwayScore, 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)
|
||||
|
||||
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(hc_timage, (main_offset - int(vs_timage.size[0]/2) - hc_timage.size[0], 9))
|
||||
img.paste(score_image, (main_offset - int(score_image.size[0]/2), 15))
|
||||
if match['isLive'] == 'post':
|
||||
if intHomeScore > intAwayScore or intHomeScore == intAwayScore:
|
||||
u_image = Image.new("RGB", (hc_timage.size[0] -2, 1))
|
||||
u_image1 = ImageDraw.Draw(u_image)
|
||||
u_image1.line((0,0,hc_timage.size[0]-2,0), fill="red", width = 0)
|
||||
img.paste(u_image, (main_offset - int(vs_timage.size[0]/2)-hc_timage.size[0], hc_timage.size[1]+7))
|
||||
img.paste(ac_timage, (main_offset + int(vs_timage.size[0]/2),9))
|
||||
if match['isLive'] == 'post':
|
||||
if intHomeScore < intAwayScore or intHomeScore == intAwayScore:
|
||||
ua_image = Image.new("RGB", (ac_timage.size[0] -2, 1))
|
||||
ua_image1 = ImageDraw.Draw(ua_image)
|
||||
ua_image1.line((0,0,ac_timage.size[0]-2,0), fill="red", width = 0)
|
||||
img.paste(ua_image, (main_offset + int(vs_timage.size[0]/2), ac_timage.size[1]+7))
|
||||
x_offset = (main_offset + max(int(date_timage.size[0]/2), int(vs_timage.size[0]/2) + ac_timage.size[0], int(score_image.size[0]/2)) + 4)
|
||||
|
||||
img.paste(away_logo, (x_offset,0))
|
||||
x_offset += away_logo.size[0] + buff_size
|
||||
|
||||
img = img.crop((0,0,x_offset,32))
|
||||
imgs.append(img)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
else:
|
||||
for league in leagues:
|
||||
try:
|
||||
x_offset = 0
|
||||
if (league =='PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
else:
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
league_info = leagues_info[league]
|
||||
|
||||
|
||||
try:
|
||||
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
|
||||
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||
x_offset += self.blank.size[0]
|
||||
else:
|
||||
img.paste(league_logo, (x_offset,0))
|
||||
x_offset += league_logo.size[0] +self.blank.size[0]
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
med_font = ImageFont.load("./fonts/7x14B.pil")
|
||||
large_font = ImageFont.load("./fonts/9x18B.pil")
|
||||
extra_small_font = ImageFont.load("./fonts/4x6.pil")
|
||||
try:
|
||||
sports_info = self.readSportsCSV(league)
|
||||
except:
|
||||
pass
|
||||
|
||||
buff_size = 25
|
||||
|
||||
for match in league_info:
|
||||
|
||||
dateEvent = match['date'].replace('-', '.')
|
||||
date_timage = self.textImage(dateEvent, small_font, r=255, g=255, b=255)
|
||||
|
||||
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||
event = match['event']
|
||||
venue = match['venue']
|
||||
city = match['city']
|
||||
country = match['country']
|
||||
season = match['season']
|
||||
|
||||
if time != 'future':
|
||||
golf_standings1 = match['golf_standings'][::2]
|
||||
golf_standings2 = match['golf_standings'][1::2]
|
||||
|
||||
img.paste(league_logo, (x_offset, 0))
|
||||
x_offset += league_logo.size[0] + 2
|
||||
|
||||
if time == 'future':
|
||||
|
||||
event_timage = self.textImage(event, med_font, r=255, g=255, b=0)
|
||||
venue_timage = self.textImage(venue, small_font, r=0, g=255, b=0)
|
||||
city_timage = self.textImage(city, small_font, r=255, g=255, b=255)
|
||||
country_timage = self.textImage(country, small_font, r=255, g=255, b=255)
|
||||
date1_timage = self.textImage('Date:', small_font, r=255, g=0, b=171)
|
||||
season1_timage = self.textImage('Season:', small_font, r=0, g=170, b=255)
|
||||
season_timage = self.textImage(season, small_font, r=255, g=255, b=255)
|
||||
|
||||
#date
|
||||
img.paste(date1_timage, (x_offset + 2, 26))
|
||||
img.paste(date_timage, (x_offset + date1_timage.size[0] + 3, 26))
|
||||
#event
|
||||
img.paste(event_timage, (x_offset + 2, 0))
|
||||
#venue
|
||||
img.paste(venue_timage,(x_offset + 2, 16))
|
||||
#country
|
||||
img.paste(country_timage,(x_offset + event_timage.size[0] + 5,5))
|
||||
#city
|
||||
img.paste(city_timage,(x_offset + 15 + venue_timage.size[0], 16))
|
||||
#season
|
||||
img.paste(season1_timage,(x_offset + 2 + date1_timage.size[0] + date_timage.size[0] + 20,26))
|
||||
img.paste(season_timage,(x_offset + 2 + date1_timage.size[0] + date_timage.size[0] + 20 + season1_timage.size[0],26))
|
||||
|
||||
x_offset += max(2 + event_timage.size[0] + country_timage.size[0] + 5, 2 + venue_timage.size[0] + city_timage.size[0] + 15, 2 + date1_timage.size[0] + date_timage.size[0] + 20 + season1_timage.size[0] + season_timage.size[0] + 3)
|
||||
x_offset += buff_size
|
||||
|
||||
else:
|
||||
event_timage = self.textImage(event, med_font, r=255, g=255, b=0)
|
||||
venue_timage = self.textImage(venue, small_font, r=0, g=255, b=0)
|
||||
city_timage = self.textImage(city, small_font, r=255, g=255, b=255)
|
||||
country_timage = self.textImage(country, small_font, r=255, g=255, b=255)
|
||||
date1_timage = self.textImage('Date:', small_font, r=255, g=0, b=171)
|
||||
season1_timage = self.textImage('Season:', small_font, r=0, g=170, b=255)
|
||||
season_timage = self.textImage(season, small_font, r=255, g=255, b=255)
|
||||
|
||||
#date
|
||||
img.paste(date1_timage, (x_offset + 2, 26))
|
||||
img.paste(date_timage, (x_offset + date1_timage.size[0] + 3, 26))
|
||||
#event
|
||||
img.paste(event_timage, (x_offset + 2, 0))
|
||||
#venue
|
||||
img.paste(venue_timage,(x_offset + 2, 16))
|
||||
#country
|
||||
img.paste(country_timage,(x_offset + event_timage.size[0] + 5,5))
|
||||
#city
|
||||
img.paste(city_timage,(x_offset + 15 + venue_timage.size[0], 16))
|
||||
#season
|
||||
img.paste(season1_timage,(x_offset + 2 + date1_timage.size[0] + date_timage.size[0] + 20,26))
|
||||
img.paste(season_timage,(x_offset + 2 + date1_timage.size[0] + date_timage.size[0] + 20 + season1_timage.size[0],26))
|
||||
|
||||
x_offset += max(2 + event_timage.size[0] + country_timage.size[0] + 5, 2 + venue_timage.size[0] + city_timage.size[0] + 15, 2 + date1_timage.size[0] + date_timage.size[0] + 20 + season1_timage.size[0] + season_timage.size[0] + 3)
|
||||
x_offset2 = x_offset
|
||||
|
||||
for each_player in golf_standings1:
|
||||
symbol1_timage = self.textImage('|', small_font, r=255, g=255, b=0)
|
||||
img.paste(symbol1_timage, (x_offset + 5, 7))
|
||||
golf_standings1_timage = self.textImage(each_player, small_font, r=255, g=255, b=255)
|
||||
img.paste(golf_standings1_timage, (x_offset + symbol1_timage.size[0] + 7, 7))
|
||||
x_offset += (golf_standings1_timage.size[0] + symbol1_timage.size[0] + 7)
|
||||
|
||||
for each_player2 in golf_standings2:
|
||||
symbol2_timage = self.textImage('|', small_font, r=255, g=255, b=0)
|
||||
img.paste(symbol2_timage, (x_offset2 + 5, 20))
|
||||
golf_standings2_timage = self.textImage(each_player2, small_font, r=255, g=255, b=255)
|
||||
img.paste(golf_standings2_timage, (x_offset2 + symbol2_timage.size[0] + 7, 20))
|
||||
x_offset2 += (golf_standings2_timage.size[0] + symbol2_timage.size[0] + 7)
|
||||
|
||||
if x_offset >= x_offset2:
|
||||
x_offset += buff_size
|
||||
else:
|
||||
x_offset = x_offset2
|
||||
x_offset += buff_size
|
||||
else:
|
||||
strHomeTeam = match['home_team']
|
||||
strAwayTeam = match['away_team']
|
||||
|
||||
if time != 'future':
|
||||
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(home_logo, (x_offset,0))
|
||||
|
||||
x_offset += home_logo.size[0] + 4
|
||||
|
||||
if time == 'future':
|
||||
#img.paste(date_timage, (x_offset+5, 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
|
||||
vs_timage = self.textImage('vs', med_font, r = 255, g = 255, b = 255, h_buff = 5)
|
||||
try:
|
||||
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))
|
||||
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'], med_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_size = vs_timage.size[0] + ac_timage.size[0] + hc_timage.size[0]
|
||||
|
||||
main_offset = 5 + x_offset + int(max(vs_size, date_timage.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),9))
|
||||
img.paste(hc_timage, (main_offset - int(vs_timage.size[0]/2) - hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (main_offset + int(vs_timage.size[0]/2),9))
|
||||
x_offset = (main_offset + max(int(date_timage.size[0]/2), int(vs_timage.size[0]/2) + ac_timage.size[0]) + 6)
|
||||
else:
|
||||
score_image = self.textImage(intHomeScore + '-' + intAwayScore, 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)
|
||||
|
||||
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(hc_timage, (main_offset - int(vs_timage.size[0]/2) - hc_timage.size[0], 9))
|
||||
img.paste(score_image, (main_offset - int(score_image.size[0]/2), 15))
|
||||
if intHomeScore > intAwayScore or intHomeScore == intAwayScore:
|
||||
u_image = Image.new("RGB", (hc_timage.size[0] -2, 1))
|
||||
u_image1 = ImageDraw.Draw(u_image)
|
||||
u_image1.line((0,0,hc_timage.size[0]-2,0), fill="red", width = 0)
|
||||
img.paste(u_image, (main_offset - int(vs_timage.size[0]/2)-hc_timage.size[0], hc_timage.size[1]+7))
|
||||
img.paste(ac_timage, (main_offset + int(vs_timage.size[0]/2),9))
|
||||
if intHomeScore < intAwayScore or intHomeScore == intAwayScore:
|
||||
ua_image = Image.new("RGB", (ac_timage.size[0] -2, 1))
|
||||
ua_image1 = ImageDraw.Draw(ua_image)
|
||||
ua_image1.line((0,0,ac_timage.size[0]-2,0), fill="red", width = 0)
|
||||
img.paste(ua_image, (main_offset + int(vs_timage.size[0]/2), ac_timage.size[1]+7))
|
||||
|
||||
x_offset = (main_offset + max(int(date_timage.size[0]/2), int(vs_timage.size[0]/2) + ac_timage.size[0], int(score_image.size[0]/2)) + 4)
|
||||
|
||||
img.paste(away_logo, (x_offset,0))
|
||||
|
||||
x_offset += away_logo.size[0]
|
||||
x_offset += buff_size
|
||||
|
||||
img = img.crop((0,0,x_offset ,32))
|
||||
imgs.append(img)
|
||||
except Exception as e:
|
||||
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()
|
||||
|
||||
|
||||
|
||||
return self.stitchImage(imgs)
|
||||
|
||||
|
||||
def getLeagueTableImage(self, league = False):
|
||||
|
||||
f = open('csv/league_tables.json', 'r')
|
||||
@ -2371,9 +2787,7 @@ class StockTicker():
|
||||
|
||||
if time in ['past', 'live']:
|
||||
filepath = 'csv/{}_games.json'.format(time)
|
||||
|
||||
else:
|
||||
|
||||
filepath = 'csv/upcoming_games.json'
|
||||
|
||||
f = open(filepath, 'r')
|
||||
@ -2381,17 +2795,204 @@ class StockTicker():
|
||||
f.close()
|
||||
|
||||
title_img = self.openImage('feature_titles/sports_'+ time + '.png')
|
||||
imgs = []
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/small_feature_titles/sports_{}.png'.format(time))
|
||||
imgs = [title_img, self.blank]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
|
||||
leagues_info = all_settings['leagues']
|
||||
leagues = list(leagues_info.keys())
|
||||
|
||||
|
||||
if time == 'live':
|
||||
for league in leagues:
|
||||
try:
|
||||
x_offset = 0
|
||||
if league == 'NFL':
|
||||
f = open('csv/live_nfl.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['NFL'][0]
|
||||
elif league == 'NHL':
|
||||
f = open('csv/live_nhl.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['NHL'][0]
|
||||
elif league == 'NBA':
|
||||
f = open('csv/live_nba.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['NBA'][0]
|
||||
elif league == 'MLB':
|
||||
f = open('csv/live_mlb.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['MLB'][0]
|
||||
elif league == 'MLS':
|
||||
f = open('csv/live_mls.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['MLS'][0]
|
||||
elif league == 'PREMIERLEAGUE':
|
||||
f = open('csv/live_pl.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
league_info = all_settings['leagues']['PREMIERLEAGUE'][0]
|
||||
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
|
||||
try:
|
||||
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
|
||||
width, height = league_logo.size
|
||||
league_logo2 = league_logo.resize((int(width/2), int(height/2)))
|
||||
img.paste(league_logo2, (x_offset,0))
|
||||
x_offset += (league_logo2.size[0]+10)
|
||||
except:
|
||||
pass
|
||||
|
||||
font = ImageFont.load("./fonts/6x10.pil")
|
||||
small_font = ImageFont.load("./fonts/4x6.pil")
|
||||
|
||||
try:
|
||||
sports_info = self.readSportsCSV(league)
|
||||
except:
|
||||
pass
|
||||
|
||||
buff_size = 20
|
||||
|
||||
if all_settings['leagues'][league][2] == 'no_live' and all_settings['leagues'][league][3] == 'no_upcoming':
|
||||
no_match = self.textImage(('No live games').upper(), font, r = 255, g = 255 , b = 255)
|
||||
img.paste(no_match, (x_offset,4))
|
||||
x_offset += no_match.size[0]
|
||||
|
||||
elif all_settings['leagues'][league][3] != 'no_upcoming':
|
||||
next_match = self.textImage('Next game: ' + all_settings['leagues'][league][3], font, r=255,g=255,b=255)
|
||||
img.paste(next_match, (x_offset,4))
|
||||
x_offset += next_match.size[0]
|
||||
|
||||
else:
|
||||
|
||||
for match in league_info:
|
||||
|
||||
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']))
|
||||
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)
|
||||
|
||||
error = False
|
||||
|
||||
img.paste(home_logo1, (x_offset,0))
|
||||
x_offset += (home_logo1.size[0] + 2)
|
||||
|
||||
score_image = self.textImage(intHomeScore + '-' + intAwayScore, 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)-hc_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(hc_timage,(x_offset10, 5))
|
||||
if match['isLive'] == 'post':
|
||||
if intHomeScore > intAwayScore or intHomeScore == 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] + score_image.size[0]
|
||||
img.paste(ac_timage,(x_offset10, 5))
|
||||
if match['isLive'] == 'post':
|
||||
if intHomeScore < intAwayScore or intHomeScore == 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]
|
||||
if error:
|
||||
img.paste(away_logo1, (max(x_offset + date_timage.size[0], x_offset10),0))
|
||||
x_offset += (away_logo1.size[0] + date_timage.size[0])
|
||||
else:
|
||||
img.paste(away_logo1, (max(x_offset,x_offset10),0))
|
||||
x_offset += away_logo1.size[0]
|
||||
|
||||
|
||||
else:
|
||||
x_offset_date = (x_offset + hc_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(hc_timage, (x_offset, 5))
|
||||
|
||||
if match['isLive'] == 'post':
|
||||
if intHomeScore > intAwayScore or intHomeScore == 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]
|
||||
img.paste(score_image, (x_offset, 5))
|
||||
x_offset += score_image.size[0]
|
||||
img.paste(ac_timage, (x_offset, 5))
|
||||
if match['isLive'] == 'post':
|
||||
if intHomeScore < intAwayScore or intHomeScore == 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]
|
||||
x_offset_date += date_timage.size[0]
|
||||
if error:
|
||||
img.paste(away_logo1, (max(x_offset + date_timage.size[0], x_offset_date),0))
|
||||
x_offset += (away_logo1.size[0] + date_timage.size[0])
|
||||
else:
|
||||
img.paste(away_logo1, (max(x_offset,x_offset_date),0))
|
||||
x_offset += away_logo1.size[0]
|
||||
x_offset += buff_size
|
||||
x_offset += 20
|
||||
img = img.crop((0,0,x_offset ,16))
|
||||
imgs.append(img)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
else:
|
||||
for league in leagues:
|
||||
try:
|
||||
x_offset = 0
|
||||
@ -2403,6 +3004,10 @@ class StockTicker():
|
||||
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
|
||||
width, height = league_logo.size
|
||||
league_logo2 = league_logo.resize((int(width/2), int(height/2)))
|
||||
|
||||
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||
x_offset += 10
|
||||
else:
|
||||
img.paste(league_logo2, (x_offset,0))
|
||||
x_offset += (league_logo2.size[0]+10)
|
||||
except:
|
||||
@ -2412,12 +3017,110 @@ class StockTicker():
|
||||
font = ImageFont.load("./fonts/6x10.pil")
|
||||
small_font = ImageFont.load("./fonts/4x6.pil")
|
||||
|
||||
try:
|
||||
sports_info = self.readSportsCSV(league)
|
||||
except:
|
||||
pass
|
||||
|
||||
buff_size = 20
|
||||
|
||||
|
||||
for match in league_info:
|
||||
|
||||
dateEvent = match['date'].replace('-', '.')
|
||||
date_timage = self.textImage(dateEvent, small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||
event = match['event']
|
||||
venue = match['venue']
|
||||
city = match['city']
|
||||
country = match['country']
|
||||
season = match['season']
|
||||
|
||||
if time != 'future':
|
||||
golf_standings1 = match['golf_standings'][::2]
|
||||
golf_standings2 = match['golf_standings'][1::2]
|
||||
|
||||
img.paste(league_logo2, (x_offset, 0))
|
||||
x_offset += league_logo2.size[0] + 5
|
||||
|
||||
if time == 'future':
|
||||
|
||||
event_timage = self.textImage(event, small_font, r=255, g=255, b=0)
|
||||
venue_timage = self.textImage(venue, small_font, r=0, g=255, b=0)
|
||||
city_timage = self.textImage(city, small_font, r=255, g=255, b=255)
|
||||
country_timage = self.textImage(country, small_font, r=255, g=255, b=255)
|
||||
season1_timage = self.textImage('Season:', small_font, r=0, g=170, b=255)
|
||||
season_timage = self.textImage(season, small_font, r=255, g=255, b=255)
|
||||
date1_timage = self.textImage('Date:', small_font, r=255, g=0, b=171)
|
||||
|
||||
#event
|
||||
img.paste(event_timage, (x_offset, 1))
|
||||
#venue
|
||||
img.paste(venue_timage,(x_offset, 9))
|
||||
x_offset += (max(event_timage.size[0], venue_timage.size[0]) + 5)
|
||||
#date
|
||||
img.paste(date1_timage, (x_offset, 1))
|
||||
img.paste(date_timage, (x_offset + date1_timage.size[0] + 2, 1))
|
||||
#city
|
||||
img.paste(city_timage,(x_offset, 9))
|
||||
#country
|
||||
img.paste(country_timage,(x_offset + city_timage.size[0] + 7,9))
|
||||
#season
|
||||
img.paste(season1_timage,(x_offset + date1_timage.size[0] + 2 + date_timage.size[0] + 5,1))
|
||||
img.paste(season_timage,(x_offset + date1_timage.size[0] + 2 + date_timage.size[0] + season1_timage.size[0] + 5,1))
|
||||
|
||||
x_offset += max(date1_timage.size[0] + 2 + date_timage.size[0] + season1_timage.size[0] + 5 + season_timage.size[0], city_timage.size[0] + 7 + country_timage.size[0])
|
||||
x_offset += (buff_size - 10)
|
||||
else:
|
||||
event_timage = self.textImage(event, small_font, r=255, g=255, b=0)
|
||||
venue_timage = self.textImage(venue, small_font, r=0, g=255, b=0)
|
||||
city_timage = self.textImage(city, small_font, r=255, g=255, b=255)
|
||||
country_timage = self.textImage(country, small_font, r=255, g=255, b=255)
|
||||
season1_timage = self.textImage('Season:', small_font, r=0, g=170, b=255)
|
||||
season_timage = self.textImage(season, small_font, r=255, g=255, b=255)
|
||||
date1_timage = self.textImage('Date:', small_font, r=255, g=0, b=171)
|
||||
|
||||
#event
|
||||
img.paste(event_timage, (x_offset, 1))
|
||||
#venue
|
||||
img.paste(venue_timage,(x_offset, 9))
|
||||
x_offset += (max(event_timage.size[0], venue_timage.size[0]) + 5)
|
||||
#date
|
||||
img.paste(date1_timage, (x_offset, 1))
|
||||
img.paste(date_timage, (x_offset + date1_timage.size[0] + 2, 1))
|
||||
#city
|
||||
img.paste(city_timage,(x_offset, 9))
|
||||
#country
|
||||
img.paste(country_timage,(x_offset + city_timage.size[0] + 7,9))
|
||||
#season
|
||||
img.paste(season1_timage,(x_offset + date1_timage.size[0] + 2 + date_timage.size[0] + 5,1))
|
||||
img.paste(season_timage,(x_offset + date1_timage.size[0] + 2 + date_timage.size[0] + season1_timage.size[0] + 5,1))
|
||||
|
||||
x_offset += max(date1_timage.size[0] + 2 + date_timage.size[0] + season1_timage.size[0] + 5 + season_timage.size[0], city_timage.size[0] + 7 + country_timage.size[0])
|
||||
x_offset2 = x_offset
|
||||
|
||||
for each_player in golf_standings1:
|
||||
symbol1_timage = self.textImage('|', small_font, r=255, g=255, b=0)
|
||||
img.paste(symbol1_timage, (x_offset + 5, 1))
|
||||
golf_standings1_timage = self.textImage(each_player, small_font, r=255, g=255, b=255)
|
||||
img.paste(golf_standings1_timage, (x_offset + symbol1_timage.size[0] + 7, 1))
|
||||
x_offset += (golf_standings1_timage.size[0] + symbol1_timage.size[0] + 7)
|
||||
|
||||
for each_player2 in golf_standings2:
|
||||
symbol2_timage = self.textImage('|', small_font, r=255, g=255, b=0)
|
||||
img.paste(symbol2_timage, (x_offset2 + 5, 9))
|
||||
golf_standings2_timage = self.textImage(each_player2, small_font, r=255, g=255, b=255)
|
||||
img.paste(golf_standings2_timage, (x_offset2 + symbol2_timage.size[0] + 7, 9))
|
||||
x_offset2 += (golf_standings2_timage.size[0] + symbol2_timage.size[0] + 7)
|
||||
|
||||
if x_offset >= x_offset2:
|
||||
x_offset += (buff_size - 10)
|
||||
else:
|
||||
x_offset = x_offset2
|
||||
x_offset += (buff_size - 10)
|
||||
|
||||
else:
|
||||
strHomeTeam = match['home_team']
|
||||
strAwayTeam = match['away_team']
|
||||
|
||||
@ -2425,16 +3128,13 @@ class StockTicker():
|
||||
intHomeScore = str(match['home_score'])
|
||||
intAwayScore = str(match['away_score'])
|
||||
|
||||
dateEvent = match['date'].replace('-', '.')
|
||||
|
||||
|
||||
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.replace(' ', '\n'), font, r = 255, g = 255, b = 255)
|
||||
home_logo1 = self.textImage(strHomeTeam, small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
|
||||
try:
|
||||
@ -2443,27 +3143,38 @@ class StockTicker():
|
||||
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.replace(' ', '\n'), font, r = 255, g = 255, b = 255)
|
||||
|
||||
|
||||
date_timage = self.textImage(dateEvent, small_font, r = 255, g = 255, b = 255)
|
||||
away_logo1 = self.textImage(strAwayTeam, small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
error = False
|
||||
|
||||
img.paste(home_logo1, (x_offset,0))
|
||||
x_offset += (home_logo1.size[0] + 2)
|
||||
|
||||
|
||||
if time == 'future':
|
||||
img.paste(date_timage, (x_offset+5, 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))
|
||||
vs_timage = self.textImage('vs', font, r = 255, g = 255, b = 255, h_buff = 5)
|
||||
except:
|
||||
ac_timage = self.textImage('.', small_font, r = 255, g = 255, b = 255)
|
||||
error = True
|
||||
|
||||
vs_timage = self.textImage('vs', font, r = 255, g = 255, b = 255, h_buff = 5)
|
||||
x_offsetdate2 = x_offset + int((hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])/2)- int(date_timage.size[0]/2)
|
||||
img.paste(date_timage, (x_offsetdate2,0))
|
||||
x_offsetdate2 += date_timage.size[0]
|
||||
img.paste(hc_timage, (x_offset, 5))
|
||||
x_offset += hc_timage.size[0]
|
||||
img.paste(vs_timage, (x_offset, 5))
|
||||
@ -2472,20 +3183,46 @@ class StockTicker():
|
||||
x_offset += ac_timage.size[0]
|
||||
#x_offset += max(date_timage.size[0], (hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]))
|
||||
else:
|
||||
|
||||
score_image = self.textImage(intHomeScore + '-' + intAwayScore, 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
|
||||
|
||||
img.paste(date_timage, (x_offset+20+int((score_image.size[0] - date_timage.size[0])/2),0))
|
||||
x_offsetdate2 = x_offset + hc_timage.size[0] + int(score_image.size[0]/2)- int(date_timage.size[0]/2)
|
||||
img.paste(date_timage, (x_offsetdate2,0))
|
||||
x_offsetdate2 += date_timage.size[0]
|
||||
#img.paste(date_timage, (x_offset+20+int((score_image.size[0] - date_timage.size[0])/2),0))
|
||||
img.paste(hc_timage, (x_offset, 5))
|
||||
if intHomeScore > intAwayScore or intHomeScore == 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]
|
||||
img.paste(score_image, (x_offset, 5))
|
||||
x_offset += score_image.size[0]
|
||||
img.paste(ac_timage, (x_offset, 5))
|
||||
if intHomeScore < intAwayScore or intHomeScore == 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]
|
||||
|
||||
# if date_timage.size[0] > score_image.size[0]:
|
||||
@ -2505,16 +3242,20 @@ class StockTicker():
|
||||
|
||||
# x_offset += max( date_timage.size[0]+4, hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]+4, 2 + int(score_image.size[0]))
|
||||
|
||||
img.paste(away_logo1, (x_offset,0))
|
||||
|
||||
if error:
|
||||
img.paste(away_logo1, (max(x_offset + date_timage.size[0], x_offsetdate2),0))
|
||||
x_offset += (away_logo1.size[0] + date_timage.size[0])
|
||||
else:
|
||||
img.paste(away_logo1, (max(x_offset, x_offsetdate2),0))
|
||||
x_offset += away_logo1.size[0]
|
||||
x_offset += buff_size
|
||||
x_offset += 20
|
||||
img = img.crop((0,0,x_offset ,16))
|
||||
imgs.append(img)
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
return self.stitchImage(imgs)
|
||||
|
||||
|
||||
@ -3679,6 +4420,7 @@ class StockTicker():
|
||||
sports_stats = self.getLeagueTableProfessional()
|
||||
sports_upcoming = self.getLeagueProfessional()
|
||||
sports_past = self.getLeagueProfessional()
|
||||
sports_live = self.getLeagueProfessional()
|
||||
movies = self.getMoviesProfessional()
|
||||
messages = self.getUserMessagesProfessional()
|
||||
images = self.getUserImagesProfessional()
|
||||
@ -3704,6 +4446,8 @@ class StockTicker():
|
||||
x_offset += sports_upcoming.size[0]
|
||||
news.paste(sports_past, (x_offset, 16))
|
||||
x_offset += sports_past.size[0]
|
||||
news.paste(sports_live, (x_offset, 16))
|
||||
x_offset += sports_live.size[0]
|
||||
news.paste(movies, (x_offset, 16))
|
||||
x_offset += movies.size[0]
|
||||
news.paste(messages, (x_offset, 16))
|
||||
|
Loading…
Reference in New Issue
Block a user