From 094d2782a52998ddcdd619aca39f4f210bec8e09 Mon Sep 17 00:00:00 2001 From: Thijs Stobbelaar Date: Mon, 27 Nov 2023 21:26:08 +0100 Subject: [PATCH] s --- index.php | 17 +++++++++++++---- update/update_clan_members.ps1 | 32 +++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index d86ca4c..d645be6 100644 --- a/index.php +++ b/index.php @@ -93,14 +93,24 @@ $lastMatches = array_slice($allMatches, 0, 8); //CLANINFO $clanInfoPath = './data/claninfo.json'; $clanmembersfile = './config/clanmembers.json'; + $rankedfile = './config/player_season_data.json'; $clanmembers = json_decode(file_get_contents($clanmembersfile), true); + $playerRanks = json_decode(file_get_contents($rankedfile), true); if (file_exists($clanInfoPath)) { $clan = json_decode(file_get_contents($clanInfoPath), true); if (isset($clan) && !empty($clan)) { echo ""; - echo ""; + echo ""; foreach ($clanmembers['clanMembers'] as $value) { - echo ""; + foreach ($playerRanks as $rank) { + if ($rank['name'] == $value) { + if (isset($rank['stats']['data']['attributes']['rankedGameModeStats']['squad-fpp'])) { + echo ""; + } else { + echo ""; + } + } + } } foreach ($clan as $key => $value) { if ($key == 'updated') { @@ -108,12 +118,11 @@ $lastMatches = array_slice($allMatches, 0, 8); } echo ""; } - - echo "
AttributeValue
AttributeValueRank(FPP SQUAD)Points
name" . htmlspecialchars($value) . "
name" . htmlspecialchars($value) . "" . htmlspecialchars($rank['stats']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentTier']) . "" . htmlspecialchars($rank['stats']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentRankPoint']) . "
name" . htmlspecialchars($value) . "N/AN/A
" . htmlspecialchars($key) . "" . htmlspecialchars($value) . "
"; } else { echo "

No clan attributes available

"; } + } else { echo "

Clan info file missing

"; } diff --git a/update/update_clan_members.ps1 b/update/update_clan_members.ps1 index 03bf144..e09890f 100644 --- a/update/update_clan_members.ps1 +++ b/update/update_clan_members.ps1 @@ -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 \ No newline at end of file +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" \ No newline at end of file