-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nhlgt): update to use new NHL apis
ver(nhlgt): 2.0.0 ver(pynhlapi): 0.1.0 ver(platform): 2023.10.1
- Loading branch information
Showing
21 changed files
with
744 additions
and
727 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
APP_NAME = "pynhlapi" | ||
API_URL = "https://statsapi.web.nhl.com" | ||
SCHEDULE_ENDPOINT = "/api/v1/schedule" | ||
TEAM_ENDPOINT = "/api/v1/teams/{team_id}" | ||
TEAMS_ENDPOINT = "/api/v1/teams" | ||
GAME_ENDPOINT = "/api/v1/game/{game_pk}/feed/live" | ||
SEASON_ENDPOINT = "/api/v1/seasons/{season_id}" | ||
SEASONS_ENDPOINT = "/api/v1/seasons" | ||
STANDINGS_ENDPOINT = "/api/v1/standings" | ||
GAME_CONTENT_ENDPOINT = "/api/v1/game/{game_pk}/content" | ||
API_URL = "https://api-web.nhle.com" | ||
TEAMS_ENDPOINT = API_URL + "/v1/schedule-calendar/{ymd}" | ||
STANDINGS_ENDPOINT = API_URL + "/v1/standings/{ymd}" | ||
SCOREBOARD_ENDPOINT = API_URL + "/v1/score/{ymd}" | ||
SCHEDULE_ENDPOINT = API_URL + "/v1/schedule/{ymd}" | ||
GAME_ENDPOINT = API_URL + "/v1/gamecenter/{game_pk}/landing" | ||
SEASONS_ENDPOINT = "https://api.nhle.com/stats/rest/en/season?sort=%5B%7B%22property%22:%22id%22,%22direction%22:%22DESC%22%7D%5D" | ||
GAME_BOXSCORE_ENDPOINT = API_URL + "/v1/gamecenter/{game_pk}/boxscore" | ||
GAME_PLAYBYPLAY_ENDPOINT = API_URL + "/v1/gamecenter/{game_pk}/play-by-play" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,30 @@ | ||
<% | ||
from datetime import datetime | ||
import pytz | ||
divGames = [ | ||
x | ||
for x in data["todayOtherGames"] | ||
if ( | ||
x["teams"]["away"]["team"]["id"] in data["otherDivisionTeamIds"] | ||
or x["teams"]["home"]["team"]["id"] in data["otherDivisionTeamIds"] | ||
) and data["myTeam"]["id"] not in [ | ||
x["teams"]["away"]["team"]["id"], | ||
x["teams"]["home"]["team"]["id"], | ||
] | ||
] | ||
def subLink(t): | ||
return f"[{t['teamName']}]({data['teamSubs'].get(t['abbreviation'], '')})" | ||
return f"[{t['name']}]({data['teamSubs'].get(t['abbrev'], '')})" | ||
ordDict = {1:{1:'1st',2:'2nd',3:'3rd',4:'OT',5:'SO'},2:{1:'1st',2:'2nd',3:'3rd',4:'OT',5:'SO'},3:{1:'1st',2:'2nd',3:'3rd',4:'OT1',5:'OT2',6:'OT3',7:'OT4',8:'OT5'}} | ||
def format_period(game): | ||
return ordDict[game["gameType"]].get(game.get("period"), "") | ||
%>\ | ||
% if len(divGames): | ||
${'##'} ${data["myTeam"]["division"]["nameShort"]} Division Scoreboard | ||
% for game in divGames: | ||
% if len(data["todayOtherDivisionGames"]): | ||
${'##'} ${data["myTeam"]["divisionName"]} Division Scoreboard | ||
% for game in data["todayOtherDivisionGames"]: | ||
<% | ||
dt = datetime.strptime(game["gameDate"], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.utc) | ||
dt = datetime.strptime(game["startTimeUTC"], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.utc) | ||
toTz = pytz.timezone(settings.get("Bot", {}).get("TEAM_TIMEZONE", "America/New_York")) | ||
formattedGameTime = dt.astimezone(toTz).strftime("%I:%M %p") | ||
#formattedPeriod = "" if game["gameState"] == "FUT" else game["period"] if game.get("period") and game["period"] <= 3 else (game.get("periodDescriptor", {}).get("otPeriods", "") + "OT") if game.get("periodDescriptor", {}).get("periodType") == "OT" else "SO" if game.get("periodDescriptor", {}).get("periodType") == "SO" else game["period"] | ||
%>\ | ||
% if game["status"]["statusCode"] == "9": | ||
${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["away"]["team"]["id"]), "Unknown Team")} @ \ | ||
${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["home"]["team"]["id"]), "Unknown Team")} - PPD | ||
% elif game["status"]["abstractGameState"] == "Final": | ||
${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["away"]["team"]["id"]), "Unknown Team")} (${game["teams"]["away"]["score"]}) @ \ | ||
(${game["teams"]["home"]["score"]}) ${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["home"]["team"]["id"]), "Unknown Team")} - Final | ||
% elif game["status"]["abstractGameState"] == "Live": | ||
${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["away"]["team"]["id"]), "Unknown Team")} (${game["teams"]["away"]["score"]}) @ \ | ||
(${game["teams"]["home"]["score"]}) ${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["home"]["team"]["id"]), "Unknown Team")} \ | ||
- ${game["linescore"]["currentPeriodOrdinal"]} ${game["linescore"]["currentPeriodTimeRemaining"]} | ||
% if data["game"].get("gameScheduleState") in ["PPD", "SUSP", "CNCL"]: | ||
${subLink(game["awayTeam"])} @ ${subLink(game["homeTeam"])} - ${data["game"].get("gameScheduleState")} | ||
% elif game["gameState"] in ["FINAL", "OFF", "OVER"]: | ||
${subLink(game["awayTeam"])} @ ${subLink(game["homeTeam"])} - Final | ||
% elif game["gameState"] in ["LIVE", "CRIT"]: | ||
${subLink(game["awayTeam"])} @ ${subLink(game["homeTeam"])} - ${format_period(game)} ${game.get("clock", {}).get("timeRemaining", "")} | ||
% else: | ||
${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["away"]["team"]["id"]), "Unknown Team")} @ \ | ||
${next((subLink(t) for t in data["allTeams"] if t["id"] == game["teams"]["home"]["team"]["id"]), "Unknown Team")} \ | ||
- ${formattedGameTime} | ||
${subLink(game["awayTeam"])} @ ${subLink(game["homeTeam"])} - ${formattedGameTime} | ||
% endif | ||
|
||
% endfor | ||
% endif # if len(divGames) | ||
% endif |
Oops, something went wrong.