mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
snyc...
This commit is contained in:
@@ -493,9 +493,91 @@ class XbvrSyncService extends BaseSyncService
|
||||
return $this->updatedCount;
|
||||
}
|
||||
|
||||
protected function getDeletedCount(): int
|
||||
protected function executeCleanup(): void
|
||||
{
|
||||
return 0; // XBVR doesn't provide deletion info in this context
|
||||
$this->logProgress("Starting cleanup - detecting deleted VR scenes in XBVR...");
|
||||
|
||||
// Clean up VR scenes
|
||||
$this->cleanupScenes();
|
||||
|
||||
$this->logProgress("Cleanup completed. Deleted {$this->deletedCount} VR scenes.");
|
||||
}
|
||||
|
||||
private function cleanupScenes(): void
|
||||
{
|
||||
$this->logProgress("Checking for deleted VR scenes...");
|
||||
|
||||
try {
|
||||
// Get all scenes from XBVR
|
||||
$xbvrScenes = $this->getXbvrScenesForCleanup();
|
||||
$xbvrSceneIds = array_column($xbvrScenes, 'id');
|
||||
$this->logProgress("Found " . count($xbvrSceneIds) . " VR scenes in XBVR");
|
||||
|
||||
// Get all scenes from local database for this source
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT id, metadata FROM adult_videos WHERE source_id = :source_id
|
||||
");
|
||||
$stmt->execute(['source_id' => $this->source['id']]);
|
||||
$localScenes = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$this->logProgress("Found " . count($localScenes) . " VR scenes in local database");
|
||||
|
||||
$deletedCount = 0;
|
||||
foreach ($localScenes as $localScene) {
|
||||
$metadata = json_decode($localScene['metadata'], true);
|
||||
$xbvrId = $metadata['xbvr_id'] ?? null;
|
||||
|
||||
if ($xbvrId && !in_array($xbvrId, $xbvrSceneIds)) {
|
||||
// Scene exists in local DB but not in XBVR - delete it
|
||||
$this->deleteAdultVideo($localScene['id']);
|
||||
$deletedCount++;
|
||||
$this->deletedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->logProgress("Deleted {$deletedCount} VR scenes that no longer exist in XBVR");
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->logProgress("Error during VR scene cleanup: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function getXbvrScenesForCleanup(): array
|
||||
{
|
||||
try {
|
||||
$response = $this->httpClient->get("{$this->baseUrl}/api/scene/list", [
|
||||
'timeout' => 30,
|
||||
'connect_timeout' => 10
|
||||
]);
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$data = json_decode($response->getBody(), true);
|
||||
return $data['scenes'] ?? [];
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (Exception $e) {
|
||||
$this->logProgress("Error fetching XBVR scenes: " . $e->getMessage());
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteAdultVideo(int $videoId): void
|
||||
{
|
||||
try {
|
||||
// Delete actor relationships first
|
||||
$stmt = $this->pdo->prepare("DELETE FROM actor_adult_video WHERE adult_video_id = :adult_video_id");
|
||||
$stmt->execute(['adult_video_id' => $videoId]);
|
||||
|
||||
// Delete the video
|
||||
$stmt = $this->pdo->prepare("DELETE FROM adult_videos WHERE id = :id");
|
||||
$stmt->execute(['id' => $videoId]);
|
||||
|
||||
$this->logProgress("Deleted adult video with ID: {$videoId}");
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->logProgress("Error deleting adult video {$videoId}: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function createActorRelationships(int $adultVideoId, array $actors): void
|
||||
|
||||
Reference in New Issue
Block a user