This commit is contained in:
Lanta 2023-11-27 21:26:08 +01:00
parent b39d5b7778
commit 64e6e36736
2 changed files with 42 additions and 7 deletions

View file

@ -46,12 +46,12 @@ if ($chunk.Count -gt 0) {
}
$clanMembers = $clanMembersArray -join ','
$headers = @{
'accept' = 'application/vnd.api+json'
'Authorization' = "$apiKey"
}
$playerinfo = @()
foreach ($key in $clanmemberchunks.keys) {
@ -171,4 +171,30 @@ $lifetimestats['updated'] = $formattedString
$lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json"
remove-lock
Stop-Transcript
Stop-Transcript
$seasons = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/seasons" -Method GET -Headers $headers
$current_season = $seasons.data | Where-Object {$_.attributes.isCurrentSeason -eq $true}
$i = 0
$seasonstats = @()
while($playerinfo.data.Count -gt $i) {
write-host $clanMembersArray[$i]
try{
$rankedstat = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players/$($playerinfo.data[$i].id)/seasons/$($current_season.id)/ranked" -Method GET -Headers $headers
}catch{
write-output 'sleeping for 61 seconds'
start-sleep -Seconds 61
$rankedstat = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players/$($playerinfo.data[$i].id)/seasons/$($current_season.id)/ranked" -Method GET -Headers $headers
}
$seasonstats += [PSCustomObject]@{
stat = $rankedstat
name = $playerinfo.data[$i].attributes.name
}
$i++
}
$seasonstats | convertto-json -Depth 100| Out-File "$scriptroot/../data/player_season_data.json"