sports team stats prof
This commit is contained in:
parent
2992338dfb
commit
569d5cf106
108
stockTicker.py
108
stockTicker.py
@ -72,7 +72,8 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional,
|
'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}
|
'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')}
|
||||||
|
|
||||||
self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json',
|
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',
|
'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json',
|
||||||
@ -80,7 +81,8 @@ class StockTicker():
|
|||||||
'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json',
|
'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json',
|
||||||
'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json',
|
'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',
|
'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'}
|
'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'}
|
||||||
|
|
||||||
|
|
||||||
def openImage(self, image_file):
|
def openImage(self, image_file):
|
||||||
@ -2200,6 +2202,105 @@ class StockTicker():
|
|||||||
# logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
# logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
# logf.close()
|
# logf.close()
|
||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
|
|
||||||
|
def getLeagueTableProfessional(self, league = False):
|
||||||
|
|
||||||
|
f = open('csv/league_tables.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
leagues_info = all_settings['leagues']
|
||||||
|
|
||||||
|
leagues = list(leagues_info.keys())
|
||||||
|
|
||||||
|
if all_settings['title']:
|
||||||
|
title_img = self.openImage('feature_titles/small_feature_titles/sports_team_stats.png')
|
||||||
|
imgs = [title_img, self.blank]
|
||||||
|
else:
|
||||||
|
imgs = []
|
||||||
|
|
||||||
|
|
||||||
|
for league in leagues:
|
||||||
|
|
||||||
|
try:
|
||||||
|
x_offset = 0
|
||||||
|
|
||||||
|
img = Image.new('RGB', (10000, 32))
|
||||||
|
|
||||||
|
|
||||||
|
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]+5)
|
||||||
|
|
||||||
|
|
||||||
|
team_info = leagues_info[league]
|
||||||
|
|
||||||
|
font = ImageFont.load("./fonts/6x10.pil")
|
||||||
|
|
||||||
|
|
||||||
|
sports_info = self.readSportsCSV(league)
|
||||||
|
|
||||||
|
buff_size = 20
|
||||||
|
|
||||||
|
|
||||||
|
for team in team_info:
|
||||||
|
|
||||||
|
|
||||||
|
name_timage = self.textImage(team['name'].upper(), font, r = 255, g = 255, b = 0)
|
||||||
|
wins_timage = self.textImage('W:' + str(team['wins']), font, r = 0, g = 255, b = 0)
|
||||||
|
loss_timage = self.textImage('L:' + str(team['loss']), font, r = 255, g = 0, b = 0)
|
||||||
|
draw_timage = self.textImage('D:' + str(team['draw']), font, r = 0, g = 0, b = 255)
|
||||||
|
standing_timage = self.textImage('#' + str(team['standing']), font, r = 255, g = 255, b = 255)
|
||||||
|
|
||||||
|
|
||||||
|
img.paste(standing_timage, (x_offset, 3))
|
||||||
|
x_offset += (standing_timage.size[0])
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
|
||||||
|
logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[team['name']]['logo']))
|
||||||
|
width, height = logo.size
|
||||||
|
logo2 = logo.resize((int(width/2), int(height/2)))
|
||||||
|
img.paste(logo2, (x_offset, 0))
|
||||||
|
x_offset += (logo2.size[0] + 3)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
img.paste(name_timage, (x_offset, 3))
|
||||||
|
x_offset += (name_timage.size[0] +2)
|
||||||
|
img.paste(wins_timage, (x_offset, 3))
|
||||||
|
x_offset += (wins_timage.size[0] +2)
|
||||||
|
img.paste(loss_timage, (x_offset, 3))
|
||||||
|
x_offset += (loss_timage.size[0] +2)
|
||||||
|
img.paste(draw_timage, (x_offset, 3))
|
||||||
|
x_offset += (draw_timage.size[0]+10)
|
||||||
|
# x_offset += max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0])
|
||||||
|
#img.paste(points_timage, (x_offset, 14))
|
||||||
|
# img.paste(standing_timage, (x_offset, 22))
|
||||||
|
|
||||||
|
|
||||||
|
# x_offset += standing_timage.size[0]
|
||||||
|
|
||||||
|
# if name_timage.size[0] > max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0]) + standing_timage.size[0]:
|
||||||
|
# x_offset += name_timage.size[0] - (max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0]) + standing_timage.size[0])
|
||||||
|
# x_offset += buff_size
|
||||||
|
|
||||||
|
x_offset += 25
|
||||||
|
img1 = img.crop((0,0,x_offset ,16))
|
||||||
|
imgs.append(img1)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
|
|
||||||
def convertTemp(self,temp, setting):
|
def convertTemp(self,temp, setting):
|
||||||
if setting == 'kelvin':
|
if setting == 'kelvin':
|
||||||
temp = temp+ 273.15
|
temp = temp+ 273.15
|
||||||
@ -3171,6 +3272,7 @@ class StockTicker():
|
|||||||
commodities = self.getCommoditiesProfessional()
|
commodities = self.getCommoditiesProfessional()
|
||||||
indices = self.getIndicesProfessional()
|
indices = self.getIndicesProfessional()
|
||||||
daily_forecast = self.getDailyWeatherProfessional()
|
daily_forecast = self.getDailyWeatherProfessional()
|
||||||
|
sports_stats = self.getLeagueTableProfessional()
|
||||||
|
|
||||||
x_offset = 0
|
x_offset = 0
|
||||||
news.paste(weather, (x_offset, 16))
|
news.paste(weather, (x_offset, 16))
|
||||||
@ -3187,6 +3289,8 @@ class StockTicker():
|
|||||||
x_offset += indices.size[0]
|
x_offset += indices.size[0]
|
||||||
news.paste(daily_forecast, (x_offset, 16))
|
news.paste(daily_forecast, (x_offset, 16))
|
||||||
x_offset += daily_forecast.size[0]
|
x_offset += daily_forecast.size[0]
|
||||||
|
news.paste(sports_stats, (x_offset, 16))
|
||||||
|
x_offset += sports_stats.size[0]
|
||||||
self.double_buffer = self.matrix.CreateFrameCanvas()
|
self.double_buffer = self.matrix.CreateFrameCanvas()
|
||||||
while True:
|
while True:
|
||||||
kill = stock_ticker.scrollImage(news, offset_x = 128)
|
kill = stock_ticker.scrollImage(news, offset_x = 128)
|
||||||
|
Loading…
Reference in New Issue
Block a user