Skip to content

Commit

Permalink
Merge pull request #85 from WardBrian/national-broadcasts
Browse files Browse the repository at this point in the history
Add national broadcast data to schedule
  • Loading branch information
toddrob99 authored Aug 10, 2022
2 parents 51e63c0 + d543008 commit 65a90a5
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions statsapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def schedule(
params.update(
{
"sportId": str(sportId),
"hydrate": "decisions,probablePitcher(note),linescore",
"hydrate": "decisions,probablePitcher(note),linescore,broadcasts,game(content(media(epg)))",
}
)

Expand Down Expand Up @@ -121,7 +121,16 @@ def schedule(
"inning_state": game.get("linescore", {}).get("inningState", ""),
"venue_id": game.get("venue", {}).get("id"),
"venue_name": game.get("venue", {}).get("name"),
"national_broadcasts": list(
set(
broadcast["name"]
for broadcast in game.get("broadcasts", [])
if broadcast.get("isNational", False)
)
),
}
if game["content"].get("media", {}).get("freeGame", False):
game_info["national_broadcasts"].append("MLB.tv Free Game")
if game_info["status"] in ["Final", "Game Over"]:
if game.get("isTie"):
game_info.update({"winning_team": "Tie", "losing_Team": "Tie"})
Expand Down Expand Up @@ -1339,20 +1348,8 @@ def standings(
for div in divisions.values():
standings += div["div_name"] + "\n"
if include_wildcard:
standings += (
"{:^4} {:<21} {:^3} {:^3} {:^4} {:^4} {:^7} {:^5} {:^4}\n".format(
*[
"Rank",
"Team",
"W",
"L",
"GB",
"(E#)",
"WC Rank",
"WC GB",
"(E#)",
]
)
standings += "{:^4} {:<21} {:^3} {:^3} {:^4} {:^4} {:^7} {:^5} {:^4}\n".format(
*["Rank", "Team", "W", "L", "GB", "(E#)", "WC Rank", "WC GB", "(E#)",]
)
for t in div["teams"]:
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(
Expand Down

0 comments on commit 65a90a5

Please sign in to comment.