sk82jack / psfpl Goto Github PK
View Code? Open in Web Editor NEWA PowerShell module to connect to the FPL API
License: MIT License
A PowerShell module to connect to the FPL API
License: MIT License
Gameweek 1 cutoff hasn't happened yet, so perhaps it is expected that the "current" week returns no data, but that does mean that you can't automate a team set-up before week 1 even though the game is up and running.
I'm hoping to have a fully automated season using scheduled tasks but at the moment have no way for my script to know which gameweek it's in.
You can pull additional player data from the API using the address https://fantasy.premierleague.com/drf/element-summary/{element_id}
I'm thinking either change Get-FplPlayer to query this when selecting only 1 player or add a parameter name Detailed
or similar which will make the function go off and query this data.
Get-FplLeagueTable -LeagueId 12345 -Type Classic
errors spectacularly.
Add error handling
In Windows PowerShell only SSL3.0 and TLS1.0 are enabled by default.
On machines which haven't had newer security protocols enabled all of the commands will fail as the FPL API only supports TLS1.2.
If you use Set-FplLineup
to bring in a player you cannot captain him in the same command. This should be allowed. Error below:
PS> Set-FplLineup -PlayersIn Barnes -PlayersOut Rondon -Captain Barnes -ViceCaptain Brooks
Set-FplLineupCaptain : You cannot captain a substitute
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Public\Set-FplLineup.ps1:129 char:19
+ ... $Lineup = Set-FplLineupCaptain -Lineup $Lineup -Captain $Players.Ca ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-FplLineupCaptain
Not covering the following lines in the tests:
Code coverage report:
Covered 97.59 % of 374 analyzed Commands in 19 Files.
Missed commands:
File Function Line Command
---- -------- ---- -------
Public\Get-FplLineup.ps1 Get-FplLineup 18 if ((-not $Script:FplSessionData) -or (-not $Script:FplSessionData['FplS...
Public\Get-FplLineup.ps1 Get-FplLineup 18 -not $Script:FplSessionData
Public\Get-FplLineup.ps1 Get-FplLineup 18 -not $Script:FplSessionData['FplSession']
Public\Get-FplLineup.ps1 Get-FplLineup 19 Write-Warning 'No existing connection found'
Public\Get-FplLineup.ps1 Get-FplLineup 20 $Credential = Get-Credential -Message 'Please enter your FPL login details'
Public\Get-FplLineup.ps1 Get-FplLineup 21 Connect-Fpl -Credential $Credential
Public\Get-FplLineup.ps1 Get-FplLineup 24 $TeamId = $Script:FplSessionData['TeamID']
Public\Get-FplLineup.ps1 Get-FplLineup 26 $Response = Invoke-RestMethod -Uri "https://fantasy.premierleague.com/dr...
Public\Get-FplLineup.ps1 Get-FplLineup 28 ConvertTo-FplObject -InputObject $Response.Picks -Type 'FplLineup'
Get-FplLeagueTable needs to be a bit more user friendly in the sense I want to make ia filter to be able to filter the user's Leagues by name or something
Set-FplLineup errors if you transfer players in different positions, e.g. a forward for a midfielder.
This is related to the addition of the PlayerTransformAttribute.
Example command:
Set-FplLineup -PlayersIn @{Name = 'Rondon'; Position = 'Forward'} -PlayersOut @{Name = 'Brooks'; Position = 'Midfielder'}
Example error:
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026son; Club=Man City}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026ueta; Club=Chelsea}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026ld; Club=Liverpool}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026igne; Club=Everton}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026iop; Club=West Ham}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026; Club=Southampton}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026zard; Club=Chelsea}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026ing; Club=Man City}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026; Club=Bournemouth}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026ette; Club=Arsenal}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
Sort-Object : Unable to cast object of type 'System.Int64' to type 'FPL.Player.Position'.
At C:\Users\jdenton\Documents\GitHub\PSFPL\PSFPL\Private\Invoke-FplLineupSwap.ps1:55 char:40
+ $NewStarters = $Starters | Sort-Object $SortOrder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (@{CanSub=True; HasP\u2026rnes; Club=Burnley}:PSObject) [Sort-Object], RuntimeException
+ FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.