Skip to content

Commit 65a90a5

Browse files
authored
Merge pull request #85 from WardBrian/national-broadcasts
Add national broadcast data to schedule
2 parents 51e63c0 + d543008 commit 65a90a5

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

statsapi/__init__.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def schedule(
7777
params.update(
7878
{
7979
"sportId": str(sportId),
80-
"hydrate": "decisions,probablePitcher(note),linescore",
80+
"hydrate": "decisions,probablePitcher(note),linescore,broadcasts,game(content(media(epg)))",
8181
}
8282
)
8383

@@ -121,7 +121,16 @@ def schedule(
121121
"inning_state": game.get("linescore", {}).get("inningState", ""),
122122
"venue_id": game.get("venue", {}).get("id"),
123123
"venue_name": game.get("venue", {}).get("name"),
124+
"national_broadcasts": list(
125+
set(
126+
broadcast["name"]
127+
for broadcast in game.get("broadcasts", [])
128+
if broadcast.get("isNational", False)
129+
)
130+
),
124131
}
132+
if game["content"].get("media", {}).get("freeGame", False):
133+
game_info["national_broadcasts"].append("MLB.tv Free Game")
125134
if game_info["status"] in ["Final", "Game Over"]:
126135
if game.get("isTie"):
127136
game_info.update({"winning_team": "Tie", "losing_Team": "Tie"})
@@ -1339,20 +1348,8 @@ def standings(
13391348
for div in divisions.values():
13401349
standings += div["div_name"] + "\n"
13411350
if include_wildcard:
1342-
standings += (
1343-
"{:^4} {:<21} {:^3} {:^3} {:^4} {:^4} {:^7} {:^5} {:^4}\n".format(
1344-
*[
1345-
"Rank",
1346-
"Team",
1347-
"W",
1348-
"L",
1349-
"GB",
1350-
"(E#)",
1351-
"WC Rank",
1352-
"WC GB",
1353-
"(E#)",
1354-
]
1355-
)
1351+
standings += "{:^4} {:<21} {:^3} {:^3} {:^4} {:^4} {:^7} {:^5} {:^4}\n".format(
1352+
*["Rank", "Team", "W", "L", "GB", "(E#)", "WC Rank", "WC GB", "(E#)",]
13561353
)
13571354
for t in div["teams"]:
13581355
standings += "{div_rank:^4} {name:<21} {w:^3} {l:^3} {gb:^4} {elim_num:^4} {wc_rank:^7} {wc_gb:^5} {wc_elim_num:^4}\n".format(

0 commit comments

Comments
 (0)