Files
immich-tv-viewer/tools/immich_debug_person.ps1
T

94 lines
3.0 KiB
PowerShell

param(
[Parameter(Mandatory=$true)]
[string]$PersonId,
[string]$Server = "http://192.168.1.29:2283",
[int]$Size = 20
)
if (-not $env:IMMICH_KEY -and -not $IMMICH_KEY) {
Write-Host "ERREUR: définis d'abord la clé API :" -ForegroundColor Red
Write-Host '$env:IMMICH_KEY = "TA_CLE_API"'
exit 1
}
$key = if ($env:IMMICH_KEY) { $env:IMMICH_KEY } else { $IMMICH_KEY }
Write-Host "=== Test personne Immich ===" -ForegroundColor Cyan
Write-Host "Server : $Server"
Write-Host "PersonId : $PersonId"
Write-Host ""
Write-Host "1) Test miniature personne..." -ForegroundColor Yellow
$personThumb = "person_$($PersonId.Substring(0,8)).jpg"
curl.exe -L -H "x-api-key: $key" -o $personThumb "$Server/api/people/$PersonId/thumbnail"
Write-Host "Miniature personne sauvée : $personThumb"
Write-Host ""
Write-Host "2) Test search/metadata type IMAGE..." -ForegroundColor Yellow
$body = @{
personIds = @($PersonId)
type = "IMAGE"
size = $Size
page = 1
order = "desc"
withArchived = $true
withDeleted = $false
withPeople = $true
withStacked = $true
} | ConvertTo-Json
$result = Invoke-RestMethod `
-Uri "$Server/api/search/metadata" `
-Headers @{ "x-api-key" = $key } `
-Method POST `
-ContentType "application/json" `
-Body $body
$result | ConvertTo-Json -Depth 10 | Out-File "debug_person_$($PersonId.Substring(0,8)).json" -Encoding utf8
$items = @()
if ($result.assets -and $result.assets.items) {
$items = @($result.assets.items)
} elseif ($result.items) {
$items = @($result.items)
}
Write-Host "Nombre items IMAGE renvoyés : $($items.Count)" -ForegroundColor Green
if ($result.assets) {
Write-Host "nextPage : $($result.assets.nextPage)"
} elseif ($result.nextPage) {
Write-Host "nextPage : $($result.nextPage)"
}
if ($items.Count -eq 0) {
Write-Host ""
Write-Host "Aucun asset IMAGE. Cette personne ne devrait pas afficher de grille photo dans l'app." -ForegroundColor Red
exit 0
}
Write-Host ""
Write-Host "3) Premiers assets :" -ForegroundColor Yellow
$items | Select-Object -First 5 id,type,originalFileName,localDateTime,isArchived,isTrashed,width,height | Format-Table
$asset = $items[0]
$assetId = $asset.id
Write-Host ""
Write-Host "4) Test miniature du premier asset..." -ForegroundColor Yellow
curl.exe -L -H "x-api-key: $key" -o "asset_preview_$($assetId.Substring(0,8)).jpg" "$Server/api/assets/$assetId/thumbnail?size=preview"
curl.exe -L -H "x-api-key: $key" -o "asset_thumb_$($assetId.Substring(0,8)).jpg" "$Server/api/assets/$assetId/thumbnail?size=thumbnail"
Write-Host ""
Write-Host "Fichiers créés :" -ForegroundColor Green
Write-Host "debug_person_$($PersonId.Substring(0,8)).json"
Write-Host "asset_preview_$($assetId.Substring(0,8)).jpg"
Write-Host "asset_thumb_$($assetId.Substring(0,8)).jpg"
Write-Host ""
Write-Host "Ouvre les images téléchargées pour vérifier si les miniatures existent :" -ForegroundColor Cyan
Write-Host "start .\asset_preview_$($assetId.Substring(0,8)).jpg"
Write-Host "start .\asset_thumb_$($assetId.Substring(0,8)).jpg"