get matches from cache and lock fix
This commit is contained in:
parent
b44c11109a
commit
e1b379780e
2 changed files with 26 additions and 12 deletions
13
config/clanmembers.json
Normal file
13
config/clanmembers.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"clanMembers": [
|
||||
"Lanta01",
|
||||
"Petje1972",
|
||||
"TaGMoM",
|
||||
"r00tger",
|
||||
"Masistuta",
|
||||
"RalphNorris",
|
||||
"Jimbo_The_One",
|
||||
"SquadKiller101",
|
||||
"Pettie1972"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
. .\..\includes\ps1\lockfile.ps1
|
||||
|
||||
new-lock
|
||||
|
||||
if ($PSScriptRoot.length -eq 0) {
|
||||
$scriptroot = Get-Location
|
||||
}
|
||||
|
|
@ -9,7 +5,8 @@ else {
|
|||
$scriptroot = $PSScriptRoot
|
||||
}
|
||||
|
||||
|
||||
. $scriptroot\..\includes\ps1\lockfile.ps1
|
||||
new-lock
|
||||
|
||||
# Read the content of the file as a single string
|
||||
$fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw
|
||||
|
|
@ -22,12 +19,9 @@ else {
|
|||
Write-Output "API Key not found"
|
||||
}
|
||||
|
||||
if ($fileContent -match "\`$clanmembers\s*=\s*array\(([^)]+)\)") {
|
||||
# Remove quotes and split by comma to get individual members
|
||||
$clanMembers = ($matches[1] -replace '"|\'', '' -split ","').replace(" ", "")
|
||||
$clanMembersArray = $clanMembers.split(",").trim()
|
||||
$clanMembersArray = (Get-Content "$scriptroot/../config/clanmembers.json" | convertfrom-json).clanmembers
|
||||
Write-Output "Clan Members: $($clanMembersArray -join ', ')"
|
||||
}
|
||||
|
||||
else {
|
||||
Write-Output "Clan members not found"
|
||||
}
|
||||
|
|
@ -49,7 +43,14 @@ foreach ($player in $player_data) {
|
|||
$playermatches = @()
|
||||
foreach ($match in $lastMatches) {
|
||||
Write-Host "Getting match for $($player.attributes.name) match: $match "
|
||||
if(Test-Path "$scriptroot/../data/matches/$match.json"){
|
||||
write-output "Getting $match from cache"
|
||||
$stats = get-content "$scriptroot/../data/matches/$match.json" | convertfrom-json
|
||||
}else{
|
||||
$stats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/matches/$match" -Method GET -Headers $headers
|
||||
$stats | ConvertTo-Json -Depth 100 | Out-File "$scriptroot/../data/matches/$match.json"
|
||||
}
|
||||
|
||||
$playermatches += [PSCustomObject]@{
|
||||
stats = $stats.included.ATTRIBUTES.stats | where-object { $_.name -eq $player.attributes.name }
|
||||
matchType = $stats.data.attributes.matchtype
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue