File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 88
99
1010class _Env (BaseSettings ):
11- model_config = SettingsConfigDict (env_file = ' .env' , env_file_encoding = ' utf-8' )
11+ model_config = SettingsConfigDict (env_file = " .env" , env_file_encoding = " utf-8" )
1212 backtrace : int = Field (
1313 alias = "FPL_BACKTRACE" ,
1414 default = 3 ,
@@ -32,6 +32,10 @@ class _Env(BaseSettings):
3232 alias = "FPL_PROFILE" ,
3333 default = "" ,
3434 )
35+ sessionid : str = Field (
36+ alias = "FPL_SESSIONID" ,
37+ default = "" ,
38+ )
3539 tabulate_format : str = Field (
3640 alias = "FPL_TABULATE_FORMAT" ,
3741 default = "tsv" ,
@@ -47,5 +51,6 @@ class _Env(BaseSettings):
4751debug : typing .Final = _Env ().debug
4852lookahead : typing .Final = _Env ().lookahead
4953profile : typing .Final = _Env ().profile
54+ sessionid : typing .Final = _Env ().sessionid
5055tabulate_format : typing .Final = _Env ().tabulate_format
5156teamid : typing .Final = _Env ().teamid
Original file line number Diff line number Diff line change @@ -149,18 +149,22 @@ def picks() -> list[Persona]:
149149 """
150150 Fetches and returns the current team picks from the Fantasy Premier League API.
151151 """
152- if not conf .teamid or not conf .profile :
152+ if not conf .teamid or not conf .profile or not conf . sessionid :
153153 raise RuntimeError (
154- "Env. FPL-teamid and FPL-cookie/profile must be set. FPL-team id "
154+ "Env. FPL-teamid and FPL-cookie/profile/sessionid must be set. FPL-team id "
155155 "from URL and cookie 'pl_profile' from 'application' in chrome."
156156 )
157157
158158 response = requests .get (
159159 f"https://fantasy.premierleague.com/api/my-team/{ conf .teamid } /" ,
160- cookies = {"pl_profile" : conf .profile },
160+ cookies = {
161+ "pl_profile" : conf .profile ,
162+ "sessionid" : conf .sessionid ,
163+ },
161164 )
165+
162166 if not response :
163- raise RuntimeError ("Non 2xx status code." )
167+ raise RuntimeError ("Non 2xx status code." , response )
164168
165169 return [person (p ["element" ]) for p in response .json ()["picks" ]]
166170
You can’t perform that action at this time.
0 commit comments