Skip to content

Commit 78b2ae1

Browse files
authored
Merge pull request #105 from toddrob99/develop
v1.6.1
2 parents ecf58c8 + 88c64be commit 78b2ae1

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

statsapi/__init__.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,15 +1038,21 @@ def game_highlight_data(gamePk):
10381038
"fields": "dates,date,games,gamePk,content,highlights,items,headline,type,value,title,description,duration,playbacks,name,url",
10391039
},
10401040
)
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 []
10471049

10481050
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+
):
10501056
unorderedHighlights.update({v["date"]: v})
10511057

10521058
sortedHighlights = []
@@ -1493,10 +1499,10 @@ def standings_data(
14931499
"wc_rank": x.get("wildCardRank", "-"),
14941500
"wc_gb": x.get("wildCardGamesBack", "-"),
14951501
"wc_elim_num": x.get("wildCardEliminationNumber", "-"),
1496-
"elim_num": x["eliminationNumber"],
1502+
"elim_num": x.get("eliminationNumber", "-"),
14971503
"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", "-"),
15001506
}
15011507
divisions[x["team"]["division"]["id"]]["teams"].append(team)
15021508

statsapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env python
22

3-
VERSION = "1.6"
3+
VERSION = "1.6.1"

0 commit comments

Comments
 (0)