@@ -1038,15 +1038,21 @@ def game_highlight_data(gamePk):
1038
1038
"fields" : "dates,date,games,gamePk,content,highlights,items,headline,type,value,title,description,duration,playbacks,name,url" ,
1039
1039
},
1040
1040
)
1041
- if not len (
1042
- r ["dates" ][0 ]["games" ][0 ]["content" ]["highlights" ]["highlights" ]["items" ]
1043
- ):
1044
- return ""
1045
-
1046
- items = r ["dates" ][0 ]["games" ][0 ]["content" ]["highlights" ]["highlights" ]["items" ]
1041
+ gameHighlights = (
1042
+ r ["dates" ][0 ]["games" ][0 ]
1043
+ .get ("content" , {})
1044
+ .get ("highlights" , {})
1045
+ .get ("highlights" , {})
1046
+ )
1047
+ if not gameHighlights or not len (gameHighlights .get ("items" , [])):
1048
+ return []
1047
1049
1048
1050
unorderedHighlights = {}
1049
- for v in (x for x in items if isinstance (x , dict ) and x ["type" ] == "video" ):
1051
+ for v in (
1052
+ x
1053
+ for x in gameHighlights ["items" ]
1054
+ if isinstance (x , dict ) and x ["type" ] == "video"
1055
+ ):
1050
1056
unorderedHighlights .update ({v ["date" ]: v })
1051
1057
1052
1058
sortedHighlights = []
@@ -1493,10 +1499,10 @@ def standings_data(
1493
1499
"wc_rank" : x .get ("wildCardRank" , "-" ),
1494
1500
"wc_gb" : x .get ("wildCardGamesBack" , "-" ),
1495
1501
"wc_elim_num" : x .get ("wildCardEliminationNumber" , "-" ),
1496
- "elim_num" : x [ "eliminationNumber" ] ,
1502
+ "elim_num" : x . get ( "eliminationNumber" , "-" ) ,
1497
1503
"team_id" : x ["team" ]["id" ],
1498
- "league_rank" : x [ "leagueRank" ] ,
1499
- "sport_rank" : x [ "sportRank" ] ,
1504
+ "league_rank" : x . get ( "leagueRank" , "-" ) ,
1505
+ "sport_rank" : x . get ( "sportRank" , "-" ) ,
1500
1506
}
1501
1507
divisions [x ["team" ]["division" ]["id" ]]["teams" ].append (team )
1502
1508
0 commit comments