nesticot commited on
Commit
3ea742d
·
verified ·
1 Parent(s): f155d70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -8
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
- # im = plt.imread(image)
676
- # im = OffsetImage(im, zoom=.75)
677
- # ab = AnnotationBbox(im, (0.69, 0.765), xycoords='axes fraction', box_alignment=(0.0,0.0),bboxprops={'edgecolor':'white'})
678
- # ax1.add_artist(ab)
679
- # axim = fig.add_axes([0.25,0.76,0.12,0.12], anchor='NW', zorder=1)
680
- # axim.imshow(im)
681
- # axim.axis('off')
 
 
 
 
 
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)