Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -666,19 +666,38 @@ def server(input, output, session):
|
|
666 |
# else:
|
667 |
# raise
|
668 |
|
669 |
-
logo = nhl_logos[nhl_logos.Team==list(player_games_one['Team'])[0]].reset_index().URL[0]
|
670 |
#im = plt.imread('players/'+name+'_'+str(last_games)+'.png')
|
671 |
#ax = fig.add_axes([0,0,1,0.85], anchor='C', zorder=1)
|
672 |
#ax.imshow(im)
|
673 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
#
|
681 |
-
|
|
|
|
|
|
|
|
|
|
|
682 |
|
683 |
imr = plt.imread(logo)
|
684 |
imr = OffsetImage(imr, zoom=.1)
|
|
|
666 |
# else:
|
667 |
# raise
|
668 |
|
669 |
+
#logo = nhl_logos[nhl_logos.Team==list(player_games_one['Team'])[0]].reset_index().URL[0]
|
670 |
#im = plt.imread('players/'+name+'_'+str(last_games)+'.png')
|
671 |
#ax = fig.add_axes([0,0,1,0.85], anchor='C', zorder=1)
|
672 |
#ax.imshow(im)
|
673 |
|
674 |
+
try:
|
675 |
+
image = requests.get(f"https://api-web.nhle.com/v1/player/{index_player}/landing/").json()['headshot']
|
676 |
+
#image = "https://cms.nhl.bamgrid.com/images/headshots/current/168x168/"+str(index_player)+".png"
|
677 |
+
im = plt.imread(image)
|
678 |
+
|
679 |
+
except HTTPError as err:
|
680 |
+
if err.code == 403:
|
681 |
+
image = "https://cms.nhl.bamgrid.com/images/headshots/current/168x168/skater.png"
|
682 |
+
image = "https://assets.nhle.com/mugs/nhl/default-skater.png"
|
683 |
+
im = plt.imread(image)
|
684 |
+
else:
|
685 |
+
raise
|
686 |
+
try:
|
687 |
+
logo = nhl_logos[nhl_logos.index==card_df_player.team_id[0]].reset_index().URL[0]
|
688 |
|
689 |
+
except KeyError:
|
690 |
+
|
691 |
+
logo = 'https://a.espncdn.com/combiner/i?img=/i/teamlogos/leagues/500/nhl.png&w=1000&h=1000'
|
692 |
+
|
693 |
+
|
694 |
+
#im = plt.imread(image)
|
695 |
+
im = OffsetImage(im, zoom=.33)
|
696 |
+
ab = AnnotationBbox(im, (0.69, 0.765), xycoords='axes fraction', box_alignment=(0.0,0.0),bboxprops={'edgecolor':'white'})
|
697 |
+
ax1.add_artist(ab)
|
698 |
+
axim = fig.add_axes([0.25,0.76,0.12,0.12], anchor='NW', zorder=1)
|
699 |
+
axim.imshow(im)
|
700 |
+
axim.axis('off')
|
701 |
|
702 |
imr = plt.imread(logo)
|
703 |
imr = OffsetImage(imr, zoom=.1)
|