Skip to content

Commit

Permalink
add support for NHL leagues
Browse files Browse the repository at this point in the history
  • Loading branch information
SwapnilShahGit committed Dec 20, 2022
1 parent 0a8912f commit be28b36
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion yahoofantasy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
from .resources.week import Week # noqa: F401
from .stats.stat import Stat # noqa: F401

__version__ = "1.3.1"
__version__ = "1.3.2"

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

0 comments on commit be28b36

Please sign in to comment.