added new espn golf result formatting

This commit is contained in:
Justin 2023-05-19 16:40:59 +08:00 committed by GitHub
parent 4669a28d85
commit bb0825d5d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2955,19 +2955,32 @@ class StockTicker():
season = match['season']
if (time != 'future') and (league != 'LIV'):
golf_standings1 = match['golf_standings'][::2]
golf_standings2 = match['golf_standings'][1::2]
golf_standings1 = match['golf_rankings'][::2]
golf_standings2 = match['golf_rankings'][1::2]
elif (time!= 'future') and (league == 'LIV'):
golf_standings1 = match['golf_standings'][0][::2]
golf_standings2 = match['golf_standings'][0][1::2]
golf_standings1_teams = match['golf_standings'][1][::2]
golf_standings2_teams = match['golf_standings'][1][1::2]
golf_standings1 = match['golf_rankings'][::2]
golf_standings2 = match['golf_rankings'][1::2]
#golf_standings1_teams = match['golf_standings'][1][::2]
#golf_standings2_teams = match['golf_standings'][1][1::2]
img.paste(league_logo, (x_offset, 0))
x_offset += league_logo.size[0] + 2
try:
if match['purse'] != 'N/A' and match['purse'] != "" and match['purse'] != '0':
purse_timage = self.textImage(match['purse'], small_font, r=0,g=255,b=0)
except:
pass
try:
if match['shots_par'] != 'N/A' and match['shots_par'] != "" and match['shots_par'] != 0:
par_timage = self.textImage('Par' + str(match['shots_par']), small_font, r=255,g=127,b=80)
except:
pass
try:
if match['total_yards'] != 'N/A' and match['total_yards'] != "" and match['total_yards'] != 0:
yards_timage = self.textImage(str(match['total_yards']) + 'yds', small_font, r=255,g=127,b=80)
except:
pass
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)
@ -2976,24 +2989,52 @@ class StockTicker():
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)
x_offset += 2
x_offset_2nd = x_offset
x_offset_3rd = x_offset
#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))
img.paste(date1_timage, (x_offset, 26))
x_offset += date1_timage.size[0]
img.paste(date_timage, (x_offset, 26))
x_offset += date_timage.size[0] + 10
#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))
img.paste(season1_timage,(x_offset,26))
x_offset += season1_timage.size[0]
img.paste(season_timage,(x_offset,26))
x_offset += season_timage.size[0] + 3
#event
img.paste(event_timage, (x_offset_2nd, 0))
x_offset_2nd += event_timage.size[0] + 5
#country
img.paste(country_timage,(x_offset_2nd, 5))
x_offset_2nd += country_timage.size[0]
#venue
img.paste(venue_timage,(x_offset_3rd, 16))
x_offset_3rd += venue_timage.size[0] + 10
#city
img.paste(city_timage,(x_offset_3rd, 16))
x_offset_3rd += city_timage.size[0]
try:
if match['total_yards'] != 'N/A' and match['total_yards'] != "" and match['total_yards'] != 0:
img.paste(yards_timage, (x_offset_3rd + 10, 16))
x_offset_3rd += yards_timage.size[0] + 10
except:
pass
try:
if match['shots_par'] != 'N/A' and match['shots_par'] != "" and match['shots_par'] != 0:
img.paste(par_timage, (x_offset_3rd + 5, 16))
x_offset_3rd += par_timage.size[0] + 5
except:
pass
try:
if match['purse'] != 'N/A' and match['purse'] != "" and match['purse'] != '0':
img.paste(purse_timage, (x_offset + 7, 25))
x_offset += purse_timage.size[0] + 3 + 7
except:
pass
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 = max(x_offset, x_offset_2nd, x_offset_3rd)
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)
@ -3003,65 +3044,134 @@ class StockTicker():
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)
x_offset += 2
x_offset_2nd = x_offset
x_offset_3rd = x_offset
#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))
img.paste(date1_timage, (x_offset, 26))
x_offset += date1_timage.size[0]
img.paste(date_timage, (x_offset, 26))
x_offset += date_timage.size[0] + 10
#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))
img.paste(season1_timage,(x_offset,26))
x_offset += season1_timage.size[0]
img.paste(season_timage,(x_offset,26))
x_offset += season_timage.size[0] + 3
#event
img.paste(event_timage, (x_offset_2nd, 0))
x_offset_2nd += event_timage.size[0] + 5
#country
img.paste(country_timage,(x_offset_2nd, 5))
x_offset_2nd += country_timage.size[0]
#venue
img.paste(venue_timage,(x_offset_3rd, 16))
x_offset_3rd += venue_timage.size[0] + 10
#city
img.paste(city_timage,(x_offset_3rd, 16))
x_offset_3rd += city_timage.size[0]
try:
if match['total_yards'] != 'N/A' and match['total_yards'] != "" and match['total_yards'] != 0:
img.paste(yards_timage, (x_offset_3rd + 10, 16))
x_offset_3rd += yards_timage.size[0] + 10
except:
pass
try:
if match['shots_par'] != 'N/A' and match['shots_par'] != "" and match['shots_par'] != 0:
img.paste(par_timage, (x_offset_3rd + 5, 16))
x_offset_3rd += par_timage.size[0] + 5
except:
pass
try:
if match['purse'] != 'N/A' and match['purse'] != "" and match['purse'] != '0':
img.paste(purse_timage, (x_offset + 7, 25))
x_offset += purse_timage.size[0] + 3 + 7
except:
pass
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
x_offset = max(x_offset, x_offset_2nd, x_offset_3rd) + 5
#x_offset2 = x_offset
symbol1_timage = self.textImage('|', small_font, r=255, g=255, b=0)
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_player, each_player2 in zip(golf_standings1, golf_standings2):
img.paste(symbol1_timage, (x_offset, 7))
img.paste(symbol1_timage, (x_offset, 20))
x_offset += symbol1_timage.size[0] + 3
golf1_offset = 0
golf2_offset = 0
try:
golf1_rank_timage = self.textImage(each_player['rank'], small_font, r=255, g=255, b=255)
golf1_offset += golf1_rank_timage.size[0] + 3
img.paste(golf1_rank_timage,(x_offset, 7))
try:
golf1_country = Image.open('logos/ufc_countries/{}'.format(each_player['country'].split('/')[-1].split('&')[0]))
golf1_country.thumbnail((9000,12))
img.paste(golf1_country,(x_offset + golf1_rank_timage.size[0] + 3, 4))
golf1_offset += golf1_country.size[0] + 3
except:
pass
golf_standings1_timage = self.textImage(each_player['name'] + ' ' + each_player['score'], small_font, r=255, g=255, b=255)
img.paste(golf_standings1_timage, (x_offset + golf1_offset, 7))
golf1_offset += golf_standings1_timage.size[0]
except:
pass
try:
golf2_rank_timage = self.textImage(each_player2['rank'], small_font, r=255, g=255, b=255)
golf2_offset += golf2_rank_timage.size[0] + 3
img.paste(golf2_rank_timage,(x_offset, 20))
try:
golf2_country = Image.open('logos/ufc_countries/{}'.format(each_player2['country'].split('/')[-1].split('&')[0]))
golf2_country.thumbnail((9000,12))
img.paste(golf2_country,(x_offset + golf2_rank_timage.size[0] + 3, 17))
golf2_offset += golf2_country.size[0] + 3
except:
pass
golf_standings2_timage = self.textImage(each_player2['name'] + ' ' + each_player2['score'], small_font, r=255, g=255, b=255)
img.paste(golf_standings2_timage, (x_offset + golf2_offset, 20))
golf2_offset += golf_standings2_timage.size[0]
except:
pass
x_offset += max(golf2_offset, golf1_offset) + 5
#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)
#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 league == 'LIV':
if x_offset >= x_offset2:
x_offset += 10
x_offset2 = x_offset
else:
x_offset2 += 10
x_offset = x_offset2
# if league == 'LIV':
# if x_offset >= x_offset2:
# x_offset += 10
# x_offset2 = x_offset
# else:
# x_offset2 += 10
# x_offset = x_offset2
for each_team in golf_standings1_teams:
symbol1_timage = self.textImage('|', small_font, r=0, g=255, b=0)
img.paste(symbol1_timage, (x_offset + 5, 7))
golf_standings1_timage = self.textImage(each_team, 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_team2 in golf_standings2_teams:
symbol2_timage = self.textImage('|', small_font, r=0, g=255, b=0)
img.paste(symbol2_timage, (x_offset2 + 5, 20))
golf_standings2_timage = self.textImage(each_team2, 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)
#for each_team in golf_standings1_teams:
# symbol1_timage = self.textImage('|', small_font, r=0, g=255, b=0)
# img.paste(symbol1_timage, (x_offset + 5, 7))
# golf_standings1_timage = self.textImage(each_team, 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_team2 in golf_standings2_teams:
# symbol2_timage = self.textImage('|', small_font, r=0, g=255, b=0)
# img.paste(symbol2_timage, (x_offset2 + 5, 20))
# golf_standings2_timage = self.textImage(each_team2, 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
#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']