ufc prof
This commit is contained in:
parent
aa7a20d8f5
commit
7987fdcdbb
152
stockTicker.py
152
stockTicker.py
@ -3607,9 +3607,125 @@ class StockTicker():
|
|||||||
|
|
||||||
buff_size = 20
|
buff_size = 20
|
||||||
|
|
||||||
|
if league == 'UFC':
|
||||||
|
try:
|
||||||
|
date_img = self.textImage(league_info[0]['date'], small_font, r=0,g=150,b=255)
|
||||||
|
eventname_img = self.textImage(league_info[0]['name'].upper(), font, r=255, g=0, b=0)
|
||||||
|
venue_img = self.textImage(league_info[0]['venue'], small_font, r=255, g=255, b=0)
|
||||||
|
city_img = self.textImage(league_info[0]['city'], small_font, r=255, g=255, b=255)
|
||||||
|
try:
|
||||||
|
country_img = self.textImage(league_info[0]['country'], small_font, r=255, g=128, b=0)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
broadcast_img = self.textImage(league_info[0]['broadcast'], small_font, r=255, g=0, b=0)
|
||||||
|
time_img = self.textImage(league_info[0]['time'], small_font, r =0, g=150, b=255)
|
||||||
|
|
||||||
|
try:
|
||||||
|
img.paste(country_img, (x_offset + eventname_img.size[0] + 2, 2))
|
||||||
|
except:
|
||||||
|
country_img = 0
|
||||||
|
pass
|
||||||
|
img.paste(eventname_img, (x_offset, 0))
|
||||||
|
img.paste(city_img, (x_offset + date_img.size[0] + 3 + time_img.size[0] + 3 + broadcast_img.size[0] + 7 + venue_img.size[0] + 3, 10))
|
||||||
|
img.paste(venue_img, (x_offset + date_img.size[0] + 3 + time_img.size[0] + 3 + broadcast_img.size[0] + 7,10))
|
||||||
|
img.paste(broadcast_img, (x_offset + date_img.size[0] + 3 + time_img.size[0] + 3, 10))
|
||||||
|
img.paste(date_img, (x_offset, 10))
|
||||||
|
img.paste(time_img, (x_offset + date_img.size[0] + 3, 10))
|
||||||
|
try:
|
||||||
|
x_offset = 10 + max(x_offset + eventname_img.size[0] + 2 + country_img.size[0], x_offset + date_img.size[0] + 3 + time_img.size[0] + 3 + broadcast_img.size[0] + 7 + venue_img.size[0] + 3 + city_img.size[0])
|
||||||
|
except:
|
||||||
|
x_offset = 10 + max(x_offset + eventname_img.size[0], x_offset + date_img.size[0] + 3 + time_img.size[0] + 3 + broadcast_img.size[0] + 7 + venue_img.size[0] + 3 + city_img.size[0])
|
||||||
|
|
||||||
|
for fight in league_info[0]['fights']:
|
||||||
|
try:
|
||||||
|
if time != 'past':
|
||||||
|
fighter1_img = Image.open('logos/ufc/{}.png'.format(fight['fighter1id']))
|
||||||
|
elif time == 'past':
|
||||||
|
fighter1_img = Image.open('logos/ufc_past/{}.png'.format(fight['fighter1id']))
|
||||||
|
fighter1_img.thumbnail((9000,16))
|
||||||
|
except:
|
||||||
|
fighter1_img = Image.open('logos/unknown.png')
|
||||||
|
fighter1_img.thumbnail((9000,16))
|
||||||
|
pass
|
||||||
|
|
||||||
|
draw = ImageDraw.Draw(img, "RGBA")
|
||||||
|
name1_img = self.textImage(fight['fighter1name'].split(' ',1)[0][0] + '.' + fight['fighter1name'].split(' ',1)[1], small_font, r=255,g=255,b=255)
|
||||||
|
max_fighter1pic = max(name1_img.size[0],fighter1_img.size[0])
|
||||||
|
|
||||||
|
|
||||||
|
img.paste(fighter1_img, (x_offset + int(max_fighter1pic/2) - int(fighter1_img.size[0]/2), 0), mask=fighter1_img)
|
||||||
|
draw.rectangle([(x_offset,16),(x_offset + name1_img.size[0]-4,10)], fill=(5,5,5,200))
|
||||||
|
draw.text((x_offset + int(max_fighter1pic/2) - int(name1_img.size[0]/2),10), fight['fighter1name'].split(' ',1)[0][0] + '.' + fight['fighter1name'].split(' ',1)[1], fill=(255,255,255),font=small_font)
|
||||||
|
try:
|
||||||
|
country1_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter1country'].split('/')[-1].split('&')[0]))
|
||||||
|
country1_img.thumbnail((9000,8))
|
||||||
|
img.paste(country1_img,(x_offset, 0))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
x_offset += max_fighter1pic
|
||||||
|
try:
|
||||||
|
if time != 'past':
|
||||||
|
fighter2_img = Image.open('logos/ufc/{}.png'.format(fight['fighter2id']))
|
||||||
|
elif time == 'past':
|
||||||
|
fighter2_img = Image.open('logos/ufc_past/{}.png'.format(fight['fighter2id']))
|
||||||
|
fighter2_img.thumbnail((9000,16))
|
||||||
|
except:
|
||||||
|
fighter2_img = Image.open('logos/unknown.png')
|
||||||
|
fighter2_img.thumbnail((9000,16))
|
||||||
|
pass
|
||||||
|
|
||||||
|
weight_img = self.textImage(fight['weight_div'].upper(), small_font, r=255,g=0,b=0)
|
||||||
|
vs_img = self.textImage('VS', small_font, r=255,g=255,b=255)
|
||||||
|
|
||||||
|
if time != 'past':
|
||||||
|
odds1_img = self.textImage(fight['fighter1odds'], small_font, r=0, g=255, b=0)
|
||||||
|
odds2_img = self.textImage(fight['fighter2odds'], small_font, r=0, g=255, b=0)
|
||||||
|
max_middle = max(vs_img.size[0] + odds1_img.size[0] + odds2_img.size[0], weight_img.size[0])
|
||||||
|
img.paste(weight_img, (x_offset + int(max_middle/2) - int(weight_img.size[0]/2), 1))
|
||||||
|
img.paste(odds1_img, (x_offset + int(max_middle/2) - int(vs_img.size[0]/2) - odds1_img.size[0],8))
|
||||||
|
img.paste(vs_img, (x_offset + int(max_middle/2) - int(vs_img.size[0]/2),8))
|
||||||
|
img.paste(odds2_img, (x_offset + int(max_middle/2) + int(vs_img.size[0]/2),8))
|
||||||
|
elif time == 'past':
|
||||||
|
if fight['fighter1win']:
|
||||||
|
win1_img = self.textImage('WIN', small_font, r=0, g=255, b=0)
|
||||||
|
win2_img = self.textImage('LOSS', small_font, r=255, g=0, b=0)
|
||||||
|
elif not fight['fighter1win'] and not fight['fighter2win']:
|
||||||
|
win1_img = self.textImage('DRAW', small_font, r=80, g=80, b=80)
|
||||||
|
win2_img = self.textImage('DRAW', small_font, r=80, g=80, b=80)
|
||||||
|
else:
|
||||||
|
win1_img = self.textImage('LOSS', small_font, r=255, g=0, b=0)
|
||||||
|
win2_img = self.textImage('WIN', small_font, r=0, g=255, b=0)
|
||||||
|
max_middle = max(vs_img.size[0] + win1_img.size[0] + win2_img.size[0], weight_img.size[0])
|
||||||
|
img.paste(weight_img, (x_offset + int(max_middle/2) - int(weight_img.size[0]/2), 1))
|
||||||
|
img.paste(win1_img, (x_offset + int(max_middle/2) - int(vs_img.size[0]/2) - int(win1_img.size[0]),8))
|
||||||
|
img.paste(vs_img, (x_offset + int(max_middle/2) - int(vs_img.size[0]/2),8))
|
||||||
|
img.paste(win2_img, (x_offset + int(max_middle/2) + int(vs_img.size[0]/2),8))
|
||||||
|
x_offset += max_middle
|
||||||
|
|
||||||
|
name2_img = self.textImage(fight['fighter2name'].split(' ',1)[0][0] + '.' + fight['fighter2name'].split(' ',1)[1], small_font, r=255,g=255,b=255)
|
||||||
|
max_fighter2pic = max(name2_img.size[0],fighter2_img.size[0])
|
||||||
|
|
||||||
|
img.paste(fighter2_img, (x_offset + int(max_fighter2pic/2) - int(fighter2_img.size[0]/2), 0), mask=fighter2_img)
|
||||||
|
draw.rectangle([(x_offset,16),(x_offset + name2_img.size[0]-4,10)], fill=(5,5,5,200))
|
||||||
|
draw.text((x_offset + int(max_fighter2pic/2) - int(name2_img.size[0]/2),10), fight['fighter2name'].split(' ',1)[0][0] + '.' + fight['fighter2name'].split(' ',1)[1], fill=(255,255,255),font=small_font)
|
||||||
|
|
||||||
|
try:
|
||||||
|
country2_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter2country'].split('/')[-1].split('&')[0]))
|
||||||
|
country2_img.thumbnail((9000,8))
|
||||||
|
img.paste(country2_img,(x_offset + max_fighter2pic - country2_img.size[0] - 2, 0))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
x_offset += max_fighter2pic + 15
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# DONT FORGET TO CHANGE DIRECTORY FOR PAST UFC GAMES
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
for match in league_info:
|
for match in league_info:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dateEvent = match['date2']
|
dateEvent = match['date2']
|
||||||
except:
|
except:
|
||||||
@ -3732,7 +3848,6 @@ class StockTicker():
|
|||||||
img.paste(golf_standings2_timage, (x_offset2 + symbol2_timage.size[0] + 7, 9))
|
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)
|
x_offset2 += (golf_standings2_timage.size[0] + symbol2_timage.size[0] + 7)
|
||||||
|
|
||||||
|
|
||||||
if x_offset >= x_offset2:
|
if x_offset >= x_offset2:
|
||||||
x_offset += (buff_size - 10)
|
x_offset += (buff_size - 10)
|
||||||
else:
|
else:
|
||||||
@ -3748,16 +3863,13 @@ class StockTicker():
|
|||||||
intAwayScore = str(match['away_score'])
|
intAwayScore = str(match['away_score'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strHomeTeam]['logo']))
|
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strHomeTeam]['logo']))
|
||||||
width1, height1 = home_logo.size
|
width1, height1 = home_logo.size
|
||||||
home_logo1 = home_logo.resize((int(width1/2), int(height1/2)))
|
home_logo1 = home_logo.resize((int(width1/2), int(height1/2)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
home_logo1 = self.textImage(strHomeTeam, small_font, r = 255, g = 255, b = 255)
|
home_logo1 = self.textImage(strHomeTeam, small_font, r = 255, g = 255, b = 255)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
|
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[strAwayTeam]['logo']))
|
||||||
width2, height2 = away_logo.size
|
width2, height2 = away_logo.size
|
||||||
away_logo1 = away_logo.resize((int(width2/2), int(height2/2)))
|
away_logo1 = away_logo.resize((int(width2/2), int(height2/2)))
|
||||||
@ -3810,15 +3922,6 @@ class StockTicker():
|
|||||||
img.paste(hc_timage, (x_offset, 5))
|
img.paste(hc_timage, (x_offset, 5))
|
||||||
x_offset += hc_timage.size[0]
|
x_offset += hc_timage.size[0]
|
||||||
|
|
||||||
#img.paste(date_timage, (x_offsetdate2,0))
|
|
||||||
#x_offsetdate2 += date_timage.size[0]
|
|
||||||
#img.paste(ac_timage, (x_offset, 5))
|
|
||||||
#x_offset += ac_timage.size[0]
|
|
||||||
#img.paste(vs_timage, (x_offset, 5))
|
|
||||||
#x_offset += vs_timage.size[0]
|
|
||||||
#img.paste(hc_timage, (x_offset, 5))
|
|
||||||
#x_offset += hc_timage.size[0]
|
|
||||||
#x_offset += max(date_timage.size[0], (hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]))
|
|
||||||
else:
|
else:
|
||||||
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:
|
try:
|
||||||
@ -3862,23 +3965,6 @@ class StockTicker():
|
|||||||
img.paste(u_image, (x_offset, hc_timage.size[1]+4))
|
img.paste(u_image, (x_offset, hc_timage.size[1]+4))
|
||||||
x_offset += hc_timage.size[0]
|
x_offset += hc_timage.size[0]
|
||||||
|
|
||||||
# if date_timage.size[0] > score_image.size[0]:
|
|
||||||
# img.paste(date_timage, (x_offset+2, 0))
|
|
||||||
# img.paste(hc_timage, (x_offset+6, 5))
|
|
||||||
# img.paste(vs_timage, (x_offset+5 + hc_timage.size[0], 5))
|
|
||||||
# img.paste(ac_timage, (x_offset+6 + hc_timage.size[0] + vs_timage.size[0], 5))
|
|
||||||
# img.paste(score_image, (x_offset + 2 + int((date_timage.size[0] - score_image.size[0])/2), 5))
|
|
||||||
# else:
|
|
||||||
|
|
||||||
# img.paste(date_timage, (x_offset+1+int((score_image.size[0] - date_timage.size[0] )/2), 0))
|
|
||||||
# vs_size = hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]
|
|
||||||
# img.paste(hc_timage, (x_offset + 1 + int((score_image.size[0] - vs_size)/2), 5))
|
|
||||||
# img.paste(vs_timage, (x_offset + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0], 5))
|
|
||||||
# img.paste(ac_timage, (x_offset+1 + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0] + vs_timage.size[0], 5))
|
|
||||||
# img.paste(score_image, (x_offset+1, 5))
|
|
||||||
|
|
||||||
# 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]))
|
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
img.paste(home_logo1, (max(x_offset + date_timage.size[0], x_offsetdate2),0))
|
img.paste(home_logo1, (max(x_offset + date_timage.size[0], x_offsetdate2),0))
|
||||||
x_offset += (home_logo1.size[0] + date_timage.size[0])
|
x_offset += (home_logo1.size[0] + date_timage.size[0])
|
||||||
@ -3886,13 +3972,13 @@ class StockTicker():
|
|||||||
img.paste(home_logo1, (max(x_offset, x_offsetdate2),0))
|
img.paste(home_logo1, (max(x_offset, x_offsetdate2),0))
|
||||||
x_offset += home_logo1.size[0]
|
x_offset += home_logo1.size[0]
|
||||||
x_offset += buff_size
|
x_offset += buff_size
|
||||||
x_offset += 20
|
|
||||||
|
x_offset += 20 #INDENT THIS OR NO?
|
||||||
img = img.crop((0,0,x_offset ,16))
|
img = img.crop((0,0,x_offset ,16))
|
||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user