Merge pull request #100 from OpzekerIT/dev
matches from cache en lock fix
This commit is contained in:
commit
7934c7ccea
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) {
|
if ($PSScriptRoot.length -eq 0) {
|
||||||
$scriptroot = Get-Location
|
$scriptroot = Get-Location
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +5,8 @@ else {
|
||||||
$scriptroot = $PSScriptRoot
|
$scriptroot = $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
. $scriptroot\..\includes\ps1\lockfile.ps1
|
||||||
|
new-lock
|
||||||
|
|
||||||
# Read the content of the file as a single string
|
# Read the content of the file as a single string
|
||||||
$fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw
|
$fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw
|
||||||
|
|
@ -22,12 +19,9 @@ else {
|
||||||
Write-Output "API Key not found"
|
Write-Output "API Key not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fileContent -match "\`$clanmembers\s*=\s*array\(([^)]+)\)") {
|
$clanMembersArray = (Get-Content "$scriptroot/../config/clanmembers.json" | convertfrom-json).clanmembers
|
||||||
# Remove quotes and split by comma to get individual members
|
Write-Output "Clan Members: $($clanMembersArray -join ', ')"
|
||||||
$clanMembers = ($matches[1] -replace '"|\'', '' -split ","').replace(" ", "")
|
|
||||||
$clanMembersArray = $clanMembers.split(",").trim()
|
|
||||||
Write-Output "Clan Members: $($clanMembersArray -join ', ')"
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
Write-Output "Clan members not found"
|
Write-Output "Clan members not found"
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +43,14 @@ foreach ($player in $player_data) {
|
||||||
$playermatches = @()
|
$playermatches = @()
|
||||||
foreach ($match in $lastMatches) {
|
foreach ($match in $lastMatches) {
|
||||||
Write-Host "Getting match for $($player.attributes.name) match: $match "
|
Write-Host "Getting match for $($player.attributes.name) match: $match "
|
||||||
$stats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/matches/$match" -Method GET -Headers $headers
|
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]@{
|
$playermatches += [PSCustomObject]@{
|
||||||
stats = $stats.included.ATTRIBUTES.stats | where-object { $_.name -eq $player.attributes.name }
|
stats = $stats.included.ATTRIBUTES.stats | where-object { $_.name -eq $player.attributes.name }
|
||||||
matchType = $stats.data.attributes.matchtype
|
matchType = $stats.data.attributes.matchtype
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue