Skip to content

Commit

Permalink
Merge pull request #129 from toddrob99/develop
Browse files Browse the repository at this point in the history
v1.7
  • Loading branch information
toddrob99 authored Oct 10, 2023
2 parents 7813caa + 1171c72 commit 6a037e4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
21 changes: 18 additions & 3 deletions statsapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,20 @@ def latest_season(sportId=1):
"seasonId": "all",
}
all_seasons = get("season", params)

return all_seasons.get("seasons")[-1]
return next(
(
x
for x in all_seasons.get("seasons", [])
if x.get("seasonStartDate")
and x.get("seasonEndDate")
and (
x["seasonStartDate"]
< datetime.today().strftime("%Y-%m-%d")
< x["seasonEndDate"]
)
),
all_seasons["seasons"][-1],
)


def lookup_player(lookup_value, gameType=None, season=None, sportId=1):
Expand Down Expand Up @@ -1679,7 +1691,10 @@ def get(endpoint, params, force=False):
% (param, ep["path_params"][param]["default"])
)
url = url.replace(
"{" + param + "}", ep["path_params"][param]["default"]
"{" + param + "}",
("/" if ep["path_params"][param]["leading_slash"] else "")
+ ep["path_params"][param]["default"]
+ ("/" if ep["path_params"][param]["trailing_slash"] else ""),
)
else:
if force:
Expand Down
4 changes: 2 additions & 2 deletions statsapi/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
},
"year": {
"type": "str",
"default": "2019", # TODO: current year or most recent draft year
"default": "",
"leading_slash": True,
"trailing_slash": False,
"required": True,
"required": False,
},
"latest": {
"type": "bool",
Expand Down
2 changes: 1 addition & 1 deletion statsapi/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python

VERSION = "1.6.2"
VERSION = "1.7"

0 comments on commit 6a037e4

Please sign in to comment.