ranks on frontpage #148
2 changed files with 42 additions and 7 deletions
17
index.php
17
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 "<table>";
|
||||
echo "<tr><th>Attribute</th><th>Value</th></tr>";
|
||||
echo "<tr><th>Attribute</th><th>Value</th><th>Rank(FPP SQUAD)</th><th>Points</th></tr>";
|
||||
foreach ($clanmembers['clanMembers'] as $value) {
|
||||
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>" . htmlspecialchars($value) . "</a></td></tr>";
|
||||
foreach ($playerRanks as $rank) {
|
||||
if ($rank['name'] == $value) {
|
||||
if (isset($rank['stats']['data']['attributes']['rankedGameModeStats']['squad-fpp'])) {
|
||||
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>" . htmlspecialchars($value) . "</a></td><td>" . htmlspecialchars($rank['stats']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentTier']) . "</td><td>" . htmlspecialchars($rank['stats']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentRankPoint']) . "</td></tr>";
|
||||
} else {
|
||||
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>" . htmlspecialchars($value) . "</a></td><td>N/A</td><td>N/A</td></tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($clan as $key => $value) {
|
||||
if ($key == 'updated') {
|
||||
|
|
@ -108,12 +118,11 @@ $lastMatches = array_slice($allMatches, 0, 8);
|
|||
}
|
||||
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<p>No clan attributes available</p>";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "<p>Clan info file missing</p>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue