From be28b36c00d2bf1a33217c7079f055caa676344d Mon Sep 17 00:00:00 2001 From: SwapnilShahGit Date: Mon, 19 Dec 2022 18:46:50 -0800 Subject: [PATCH 1/2] add support for NHL leagues --- yahoofantasy/__init__.py | 3 ++- yahoofantasy/api/games.py | 24 +++++++++++++++++++++++- yahoofantasy/stats/nhl.py | 1 + yahoofantasy/stats/utils.py | 2 ++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 yahoofantasy/stats/nhl.py diff --git a/yahoofantasy/__init__.py b/yahoofantasy/__init__.py index 341b9d2..816bdd8 100644 --- a/yahoofantasy/__init__.py +++ b/yahoofantasy/__init__.py @@ -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" + diff --git a/yahoofantasy/api/games.py b/yahoofantasy/api/games.py index 9d6e11c..ea08a5f 100644 --- a/yahoofantasy/api/games.py +++ b/yahoofantasy/api/games.py @@ -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)) diff --git a/yahoofantasy/stats/nhl.py b/yahoofantasy/stats/nhl.py new file mode 100644 index 0000000..5ba5b9e --- /dev/null +++ b/yahoofantasy/stats/nhl.py @@ -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}} \ No newline at end of file diff --git a/yahoofantasy/stats/utils.py b/yahoofantasy/stats/utils.py index e99c8c4..3440dd9 100644 --- a/yahoofantasy/stats/utils.py +++ b/yahoofantasy/stats/utils.py @@ -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 } From 58c8effa1151342086b6c72d7c3539df21e19829 Mon Sep 17 00:00:00 2001 From: SwapnilShahGit Date: Tue, 20 Dec 2022 10:42:55 -0800 Subject: [PATCH 2/2] making PR feedback changes --- .gitignore | 2 ++ README.md | 2 +- yahoofantasy/__init__.py | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a20c456..389296f 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,5 @@ venv.bak/ # mypy .mypy_cache/ + +.DS_Store/ \ No newline at end of file diff --git a/README.md b/README.md index 21f69d9..7057476 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/yahoofantasy/__init__.py b/yahoofantasy/__init__.py index 816bdd8..341b9d2 100644 --- a/yahoofantasy/__init__.py +++ b/yahoofantasy/__init__.py @@ -7,5 +7,4 @@ from .resources.week import Week # noqa: F401 from .stats.stat import Stat # noqa: F401 -__version__ = "1.3.2" - +__version__ = "1.3.1"