lpga and pga world rankings
This commit is contained in:
parent
bd630e9229
commit
ea5fd4afb1
197
stockTicker.py
197
stockTicker.py
@ -3196,7 +3196,6 @@ class StockTicker():
|
|||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
leagues_info = all_settings['leagues']
|
leagues_info = all_settings['leagues']
|
||||||
|
|
||||||
leagues = list(leagues_info.keys())
|
leagues = list(leagues_info.keys())
|
||||||
@ -3213,77 +3212,159 @@ class StockTicker():
|
|||||||
x_offset = 0
|
x_offset = 0
|
||||||
|
|
||||||
img = Image.new('RGB', (10000, 32))
|
img = Image.new('RGB', (10000, 32))
|
||||||
|
|
||||||
|
if league == 'PGA':
|
||||||
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
|
league_logo = Image.open('logos/sports/league_logos/pga_1.png').convert('RGB')
|
||||||
|
elif league == 'LPGA':
|
||||||
|
league_logo = Image.open('logos/sports/league_logos/lpga_1.png').convert('RGB')
|
||||||
|
else:
|
||||||
|
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
|
||||||
img.paste(league_logo, (x_offset,0))
|
img.paste(league_logo, (x_offset,0))
|
||||||
x_offset += league_logo.size[0] +self.blank.size[0]
|
x_offset += league_logo.size[0] +self.blank.size[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
team_info = leagues_info[league]
|
team_info = leagues_info[league]
|
||||||
|
|
||||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||||
med_font = ImageFont.load("./fonts/8x13B.pil")
|
med_font = ImageFont.load("./fonts/8x13B.pil")
|
||||||
large_font = ImageFont.load("./fonts/10x20.pil")
|
large_font = ImageFont.load("./fonts/10x20.pil")
|
||||||
|
|
||||||
|
|
||||||
#if league =='NHL': # read the NHl info from the csv, prem will need this as well
|
#if league =='NHL': # read the NHl info from the csv, prem will need this as well
|
||||||
sports_info = self.readSportsCSV(league) # gets colour and symbol info etc from csv
|
try:
|
||||||
|
sports_info = self.readSportsCSV(league) # gets colour and symbol info etc from csv
|
||||||
|
except:
|
||||||
|
pass
|
||||||
buff_size = 20
|
buff_size = 20
|
||||||
|
|
||||||
for team in team_info:
|
for team in team_info:
|
||||||
|
if league == 'PGA' or league =='LPGA':
|
||||||
try:
|
pga_font = ImageFont.load("./fonts/7x14.pil")
|
||||||
|
pga_small = ImageFont.load("./fonts/5x8.pil")
|
||||||
|
try:
|
||||||
logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[team['name']]['logo']))
|
if league == 'PGA':
|
||||||
|
player_img = Image.open('logos/pga_rank/' + team['photo'].split('/')[-1].split('&')[0])
|
||||||
|
elif league == 'LPGA':
|
||||||
|
player_img = Image.open('logos/lpga_rank/' + team['photo'].split('/')[-1])
|
||||||
|
player_img.thumbnail((9000,32))
|
||||||
|
try:
|
||||||
|
img.paste(player_img, (x_offset, 0), mask=player_img)
|
||||||
|
except:
|
||||||
|
img.paste(player_img, (x_offset, 0))
|
||||||
|
x_offset += player_img.size[0] + 2
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
x_offset2 = x_offset
|
||||||
|
if league == 'LPGA':
|
||||||
|
if str(abs(team['rank_change'])) != '-' and str(abs(team['rank_change'])) != '0':
|
||||||
|
if int(team['rank_change']) > 0:
|
||||||
|
rank_change_img = self.textImage(str(abs(team['rank_change'])), pga_font, r = 0, g = 255, b = 0)
|
||||||
|
elif int(team['rank_change']) < 0:
|
||||||
|
rank_change_img = self.textImage(str(abs(team['rank_change'])), pga_font, r = 255, g = 0, b = 0)
|
||||||
|
elif league == 'PGA':
|
||||||
|
if str(team['rank_change']) != '-':
|
||||||
|
if int(team['rank_change']) > 0:
|
||||||
|
rank_change_img = self.textImage(str(abs(int(team['rank_change']))), pga_font, r = 0, g = 255, b = 0)
|
||||||
|
elif int(team['rank_change']) < 0:
|
||||||
|
rank_change_img = self.textImage(str(abs(int(team['rank_change']))), pga_font, r = 255, g = 0, b = 0)
|
||||||
|
|
||||||
|
country_img = Image.open('logos/ufc_countries/' + team['country'].split('/')[-1].split('&')[0])
|
||||||
|
country_img.thumbnail((9000,13))
|
||||||
|
img.paste(country_img, (x_offset, 0))
|
||||||
|
x_offset += country_img.size[0] + 2
|
||||||
|
rank_img = self.textImage('#' + str(team['rank']), pga_font, r = 255, g=255, b=0)
|
||||||
|
img.paste(rank_img, (x_offset, 0))
|
||||||
|
x_offset += rank_img.size[0] + 2
|
||||||
|
name_img = self.textImage(team['first_name'].upper()[0] + '. ' + team['last_name'].upper(), pga_font, r= 255, g = 255, b = 255)
|
||||||
|
img.paste(name_img, (x_offset, 0))
|
||||||
|
x_offset += name_img.size[0] + 5
|
||||||
|
|
||||||
|
if league == 'LPGA':
|
||||||
|
if str(abs(int(team['rank_change']))) != '-' and str(abs(int(team['rank_change']))) != '0':
|
||||||
|
try:
|
||||||
|
x_offset = x_offset - 3
|
||||||
|
up_img = Image.open('logos/up-tiny.png')
|
||||||
|
down_img = Image.open('logos/down-tiny.png')
|
||||||
|
if int(team['rank_change']) > 0:
|
||||||
|
img.paste(up_img, (x_offset, 6))
|
||||||
|
x_offset += up_img.size[0] + 2
|
||||||
|
elif int(team['rank_change']) < 0:
|
||||||
|
img.paste(down_img, (x_offset, 6))
|
||||||
|
x_offset += down_img.size[0] + 2
|
||||||
|
img.paste(rank_change_img, (x_offset, 0))
|
||||||
|
x_offset += rank_change_img.size[0] + 5
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif league == 'PGA':
|
||||||
|
if str(team['rank_change']) != '-':
|
||||||
|
try:
|
||||||
|
x_offset = x_offset - 3
|
||||||
|
up_img = Image.open('logos/up-tiny.png')
|
||||||
|
down_img = Image.open('logos/down-tiny.png')
|
||||||
|
if int(team['rank_change']) > 0:
|
||||||
|
img.paste(up_img, (x_offset, 6))
|
||||||
|
x_offset += up_img.size[0] + 2
|
||||||
|
elif int(team['rank_change']) < 0:
|
||||||
|
img.paste(down_img, (x_offset, 6))
|
||||||
|
x_offset += down_img.size[0] + 2
|
||||||
|
img.paste(rank_change_img, (x_offset, 0))
|
||||||
|
x_offset += rank_change_img.size[0] + 5
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
totalpts_img = self.textImage('Total:', pga_small, r = 255, g = 255, b = 255)
|
||||||
|
totalpts2_img = self.textImage(str(team['total_pts']), pga_small, r = 0, g = 255, b = 0)
|
||||||
|
img.paste(totalpts_img, (x_offset2, 14))
|
||||||
|
img.paste(totalpts2_img, (x_offset2 + totalpts_img.size[0] + 2, 14))
|
||||||
|
|
||||||
|
avgpts_img = self.textImage('Avg:', pga_small, r = 255, g = 255, b = 255)
|
||||||
|
avgpts2_img = self.textImage(str(team['avg_pts']), pga_small, r = 0, g = 0, b = 255)
|
||||||
|
img.paste(avgpts_img, (x_offset2, 23))
|
||||||
|
img.paste(avgpts2_img, (x_offset2 + 2 + avgpts_img.size[0], 23))
|
||||||
|
events_img = self.textImage('Events:', pga_small, r= 255, g = 255, b = 255)
|
||||||
|
events2_img = self.textImage(str(team['events_played']), pga_small, r= 255, g = 128, b = 0)
|
||||||
|
img.paste(events_img, (x_offset2 + 10 + avgpts_img.size[0] + 2 + avgpts2_img.size[0], 23))
|
||||||
|
img.paste(events2_img, (x_offset2 + 10 + avgpts_img.size[0] + 2 + avgpts2_img.size[0] + 2 + events_img.size[0], 23))
|
||||||
|
try:
|
||||||
|
ptsgained_img = self.textImage('+'+str(team['gained_pts']), pga_small, r=0, g= 255, b=0)
|
||||||
|
ptslost_img = self.textImage(str(team['lost_pts']), pga_small, r=255, g= 0, b=0)
|
||||||
|
img.paste(ptsgained_img, (x_offset2 + totalpts_img.size[0] + 2 + totalpts2_img.size[0] + 5, 14))
|
||||||
|
img.paste(ptslost_img, (x_offset2 + totalpts_img.size[0] + 2 + totalpts2_img.size[0] + 5 + ptsgained_img.size[0] + 3, 14))
|
||||||
|
x_offset2 += max(avgpts_img.size[0] + 2 + avgpts2_img.size[0] + 10 + events_img.size[0] + 2 + events2_img.size[0], totalpts_img.size[0] + 2 + totalpts2_img.size[0] + 5 + ptsgained_img.size[0] + 3 + ptslost_img.size[0])
|
||||||
|
except:
|
||||||
|
x_offset2 += max(avgpts_img.size[0] + 2 + avgpts2_img.size[0] + 10 + events_img.size[0] + 2 + events2_img.size[0], 2 + totalpts_img.size[0] + totalpts2_img.size[0])
|
||||||
|
pass
|
||||||
|
|
||||||
|
x_offset = max(x_offset, x_offset2) + 20
|
||||||
|
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[team['name']]['logo']))
|
||||||
|
img.paste(logo, (x_offset, 0))
|
||||||
|
x_offset += logo.size[0] + 2
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
name_timage = self.textImage(team['name'], med_font, r = 255, g = 255, b = 0)
|
||||||
|
wins_timage = self.textImage('Wins:' + str(team['wins']), small_font, r = 0, g = 255, b = 0)
|
||||||
|
loss_timage = self.textImage('Losses:' + str(team['loss']), small_font, r = 255, g = 0, b = 0)
|
||||||
|
draw_timage = self.textImage('Draws:' + str(team['draw']), small_font, r = 0, g = 0, b = 255)
|
||||||
|
standing_timage = self.textImage('Standing:' + str(team['standing']), small_font, r = 255, g = 255, b = 255)
|
||||||
|
|
||||||
|
img.paste(name_timage, (x_offset, -1))
|
||||||
img.paste(logo, (x_offset, 0))
|
img.paste(wins_timage, (x_offset, 12))
|
||||||
x_offset += logo.size[0] + 2
|
img.paste(loss_timage, (x_offset, 19))
|
||||||
except Exception as e:
|
img.paste(draw_timage, (x_offset, 26))
|
||||||
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()
|
|
||||||
|
|
||||||
|
x_offset += max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0])
|
||||||
|
img.paste(standing_timage, (x_offset, 22))
|
||||||
|
|
||||||
name_timage = self.textImage(team['name'], med_font, r = 255, g = 255, b = 0)
|
x_offset += standing_timage.size[0]
|
||||||
wins_timage = self.textImage('Wins:' + str(team['wins']), small_font, r = 0, g = 255, b = 0)
|
|
||||||
loss_timage = self.textImage('Losses:' + str(team['loss']), small_font, r = 255, g = 0, b = 0)
|
if name_timage.size[0] > max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0]) + standing_timage.size[0]:
|
||||||
draw_timage = self.textImage('Draws:' + str(team['draw']), small_font, r = 0, g = 0, b = 255)
|
x_offset += name_timage.size[0] - (max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0]) + standing_timage.size[0])
|
||||||
#points_timage = self.textImage('Points:' + team['points'], small_font, r = 255, g = 255, b = 255)
|
x_offset += buff_size
|
||||||
standing_timage = self.textImage('Standing:' + str(team['standing']), small_font, r = 255, g = 255, b = 255)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
img.paste(name_timage, (x_offset, -1))
|
|
||||||
img.paste(wins_timage, (x_offset, 12))
|
|
||||||
img.paste(loss_timage, (x_offset, 19))
|
|
||||||
img.paste(draw_timage, (x_offset, 26))
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
img = img.crop((0,0,x_offset ,32))
|
img = img.crop((0,0,x_offset ,32))
|
||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
# logf = open('log.txt', "a")
|
# logf = open('log.txt', "a")
|
||||||
|
Loading…
Reference in New Issue
Block a user