actors the i dont know xD

This commit is contained in:
Lars Behrends
2025-11-07 13:20:48 +01:00
parent 5d86fcfda9
commit 3f2f80de11
10 changed files with 602 additions and 135 deletions

View File

@@ -656,13 +656,32 @@ class StashSyncService extends BaseSyncService
$name = $performer['name'] ?? '';
if (empty($name)) return null;
// Check if actor already exists
// Check if actor already exists by name or alias
// First check by exact name
$stmt = $this->pdo->prepare("
SELECT id, name, thumbnail_path, metadata FROM actors WHERE name = :name
SELECT id, name, thumbnail_path, metadata FROM actors
WHERE name = :name
");
$stmt->execute(['name' => $name]);
$existingActor = $stmt->fetch(PDO::FETCH_ASSOC);
// If not found by name, check aliases in PHP
if (!$existingActor) {
$stmt = $this->pdo->prepare("SELECT id, name, thumbnail_path, metadata FROM actors");
$stmt->execute();
$allActors = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($allActors as $actor) {
$metadata = json_decode($actor['metadata'] ?? '{}', true);
$aliases = $metadata['aliases'] ?? [];
if (is_array($aliases) && in_array($name, $aliases)) {
$existingActor = $actor;
$this->logProgress("Found existing actor '{$actor['name']}' by alias '{$name}'");
break;
}
}
}
// Prepare rich metadata from Stash performer data
$actorMetadata = [
'stash_id' => $performer['id'] ?? null,
@@ -908,8 +927,9 @@ class StashSyncService extends BaseSyncService
try {
$this->logProgress('Starting existing performers sync with Stash...');
echo "Starting existing performers sync with Stash..\n";
// Get all existing actors from database
$stmt = $this->pdo->prepare("SELECT id, name, metadata FROM actors ORDER BY name ASC");
$stmt = $this->pdo->prepare("SELECT id, name, metadata FROM actors WHERE id IN (SELECT actor_id FROM actor_adult_video) ORDER BY name ASC");
$stmt->execute();
$existingActors = $stmt->fetchAll(\PDO::FETCH_ASSOC);