Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for NHL leagues #50

Merged
merged 2 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ venv.bak/

# mypy
.mypy_cache/

.DS_Store/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Yahoo Fantasy Sports API is difficult to comprehend, has [this strange one-page documentation setup](https://developer.yahoo.com/fantasysports/guide/) that is hard to navigate, and seems to only want to conform to a small portion of the OAuth spec. This library/SDK makes your life easier if you want to write an app that interfaces with the Yahoo Fantasy Sports API.

This library will, in theory, work for any Yahoo Fantasy Sports API leagues/teams. It contains some common constructs and helper methods for head-to-head leagues and the sports of NFL 🏈, MLB ⚾, and NBA 🏀 at this time. More sports and league types are planned for the future.
This library will work for any Yahoo Fantasy Sports API leagues/teams. It contains some common constructs and helper methods for head-to-head leagues for the NFL 🏈, MLB ⚾, NHL 🏒 and NBA 🏀.

## Table of Contents

Expand Down
24 changes: 23 additions & 1 deletion yahoofantasy/api/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,34 @@
games["nba"]["2021"] = 410
games["nba"]["2022"] = 418

games["nhl"]["2001"] = 15
games["nhl"]["2002"] = 64
games["nhl"]["2003"] = 94
games["nhl"]["2004"] = 111
games["nhl"]["2005"] = 130
games["nhl"]["2006"] = 164
games["nhl"]["2007"] = 186
games["nhl"]["2008"] = 210
games["nhl"]["2009"] = 233
games["nhl"]["2010"] = 248
games["nhl"]["2011"] = 263
games["nhl"]["2012"] = 303
games["nhl"]["2013"] = 321
games["nhl"]["2014"] = 341
games["nhl"]["2015"] = 352
games["nhl"]["2016"] = 363
games["nhl"]["2017"] = 376
games["nhl"]["2018"] = 386
games["nhl"]["2019"] = 396
games["nhl"]["2020"] = 403
games["nhl"]["2021"] = 411
games["nhl"]["2022"] = 419

def get_game_id(game, season):
season = str(season)
if game not in games:
raise ValueError(
"{} is not a valid game, must be 'mlb', 'nba' or 'nfl'".format(game)
"{} is not a valid game, must be 'mlb', 'nba', 'nhl' or 'nfl'".format(game)
)
if season not in games[game]:
raise ValueError("{} is not a valid season for {}".format(season, game))
Expand Down
1 change: 1 addition & 0 deletions yahoofantasy/stats/nhl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stats={"0": {"name": "Games Played", "display": "GP", "order": 1}, "1": {"name": "Goals", "display": "G", "order": 1}, "2": {"name": "Assists", "display": "A", "order": 1}, "3": {"name": "Points", "display": "P", "order": 1}, "4": {"name": "Plus/Minus", "display": "+/-", "order": 1}, "5": {"name": "Penalty Minutes", "display": "PIM", "order": 1}, "6": {"name": "Powerplay Goals", "display": "PPG", "order": 1}, "7": {"name": "Powerplay Assists", "display": "PPA", "order": 1}, "8": {"name": "Powerplay Points", "display": "PPP", "order": 1}, "9": {"name": "Shorthanded Goals", "display": "SHG", "order": 1}, "10": {"name": "Shorthanded Assists", "display": "SHA", "order": 1}, "11": {"name": "Shorthanded Points", "display": "SHP", "order": 1}, "12": {"name": "Game-Winning Goals", "display": "GWG", "order": 1}, "13": {"name": "Game-Tying Goals", "display": "GTG", "order": 1}, "14": {"name": "Shots on Goal", "display": "SOG", "order": 1}, "15": {"name": "Shooting Percentage", "display": "SH%", "order": 1}, "16": {"name": "Faceoffs Won", "display": "FW", "order": 1}, "17": {"name": "Faceoffs Lost", "display": "FL", "order": 0}, "18": {"name": "Games Started", "display": "GS", "order": 1}, "19": {"name": "Wins", "display": "W", "order": 1}, "20": {"name": "Losses", "display": "L", "order": 0}, "21": {"name": "Ties", "display": "T", "order": 1}, "22": {"name": "Goals Against", "display": "GA", "order": 0}, "23": {"name": "Goals Against Average", "display": "GAA", "order": 0}, "24": {"name": "Shots Against", "display": "SA", "order": 1}, "25": {"name": "Saves", "display": "SV", "order": 1}, "26": {"name": "Save Percentage", "display": "SV%", "order": 1}, "27": {"name": "Shutouts", "display": "SHO", "order": 1}, "28": {"name": "Time on Ice", "display": "TOI", "order": 1}, "29": {"name": "F/D Games", "display": "GP", "order": 1}, "30": {"name": "Goalie Games", "display": "GP", "order": 1}, "31": {"name": "Hits", "display": "HIT", "order": 1}, "32": {"name": "Blocks", "display": "BLK", "order": 1}, "33": {"name": "Time on Ice", "display": "TOI", "order": 1}, "34": {"name": "Average Time on Ice", "display": "TOI/G", "order": 1}}
2 changes: 2 additions & 0 deletions yahoofantasy/stats/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from .mlb import stats as stats_mlb
from .nfl import stats as stats_nfl
from .nba import stats as stats_nba
from .nhl import stats as stats_nhl

league_types = {
"mlb": stats_mlb,
"nfl": stats_nfl,
"nba": stats_nba,
"nhl": stats_nhl
}


Expand Down