Skip to content

Commit

Permalink
Feature: Helpers module.
Browse files Browse the repository at this point in the history
- Contains useful but often expiremental methods for aggregation and analysis
  • Loading branch information
coreyjs committed Dec 9, 2024
1 parent a354661 commit 582d758
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
25 changes: 25 additions & 0 deletions nhlpy/api/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import List

from nhlpy.http_client import HttpClient


class Helpers:
def __init__(self, http_client: HttpClient) -> None:
self.client = http_client

def get_gameids_by_season(self, season: str) -> List[str]:
"""
Get all gameids for a given season.
:param season: The season you want the gameids for. Format is YYYYYYYY. 20202021, 200232024, etc
"""
from nhlpy.api.teams import Teams
from nhlpy.api.schedule import Schedule

teams = Teams(self.client).teams_info()

gameids = []
for team in teams:
schedule = Schedule(self.client).get_season_schedule(team["abbr"], season)
gameids.extend([game["id"] for game in schedule["games"]])

return gameids
3 changes: 2 additions & 1 deletion nhlpy/nhl_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nhlpy.api import teams, standings, schedule, game_center, stats, misc, playoffs
from nhlpy.api import teams, standings, schedule, game_center, stats, misc, playoffs, helpers
from nhlpy.http_client import HttpClient
from nhlpy.config import ClientConfig

Expand Down Expand Up @@ -36,3 +36,4 @@ def __init__(
self.stats = stats.Stats(http_client=self._http_client)
self.misc = misc.Misc(http_client=self._http_client)
self.playoffs = playoffs.Playoffs(http_client=self._http_client)
self.helpers = helpers.Helpers(http_client=self._http_client)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "nhl-api-py"
version = "2.16.0"
version = "2.17.0"
description = "NHL API (Updated for 2024/2025) and EDGE Stats. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods as well as pythonic query builder for more indepth EDGE stats."
authors = ["Corey Schaf <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 582d758

Please sign in to comment.