Skip to content

Commit 6a037e4

Browse files
authored
Merge pull request #129 from toddrob99/develop
v1.7
2 parents 7813caa + 1171c72 commit 6a037e4

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

statsapi/__init__.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,20 @@ def latest_season(sportId=1):
11951195
"seasonId": "all",
11961196
}
11971197
all_seasons = get("season", params)
1198-
1199-
return all_seasons.get("seasons")[-1]
1198+
return next(
1199+
(
1200+
x
1201+
for x in all_seasons.get("seasons", [])
1202+
if x.get("seasonStartDate")
1203+
and x.get("seasonEndDate")
1204+
and (
1205+
x["seasonStartDate"]
1206+
< datetime.today().strftime("%Y-%m-%d")
1207+
< x["seasonEndDate"]
1208+
)
1209+
),
1210+
all_seasons["seasons"][-1],
1211+
)
12001212

12011213

12021214
def lookup_player(lookup_value, gameType=None, season=None, sportId=1):
@@ -1679,7 +1691,10 @@ def get(endpoint, params, force=False):
16791691
% (param, ep["path_params"][param]["default"])
16801692
)
16811693
url = url.replace(
1682-
"{" + param + "}", ep["path_params"][param]["default"]
1694+
"{" + param + "}",
1695+
("/" if ep["path_params"][param]["leading_slash"] else "")
1696+
+ ep["path_params"][param]["default"]
1697+
+ ("/" if ep["path_params"][param]["trailing_slash"] else ""),
16831698
)
16841699
else:
16851700
if force:

statsapi/endpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@
106106
},
107107
"year": {
108108
"type": "str",
109-
"default": "2019", # TODO: current year or most recent draft year
109+
"default": "",
110110
"leading_slash": True,
111111
"trailing_slash": False,
112-
"required": True,
112+
"required": False,
113113
},
114114
"latest": {
115115
"type": "bool",

statsapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env python
22

3-
VERSION = "1.6.2"
3+
VERSION = "1.7"

0 commit comments

Comments
 (0)