mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
actors / poster images
This commit is contained in:
@@ -20,6 +20,11 @@ class XbvrSyncService extends BaseSyncService
|
||||
public function __construct(\PDO $pdo, array $source)
|
||||
{
|
||||
parent::__construct($pdo, $source);
|
||||
|
||||
// Initialize properties first before using them
|
||||
$this->apiKey = $source['api_key'];
|
||||
$this->baseUrl = rtrim($source['api_url'], '/');
|
||||
|
||||
$this->httpClient = new Client([
|
||||
'timeout' => 30,
|
||||
'headers' => [
|
||||
@@ -27,9 +32,8 @@ class XbvrSyncService extends BaseSyncService
|
||||
'X-API-Key' => $source['api_key']
|
||||
]
|
||||
]);
|
||||
$this->apiKey = $source['api_key'];
|
||||
$this->baseUrl = rtrim($source['api_url'], '/');
|
||||
$this->imageDownloader = new ImageDownloader();
|
||||
|
||||
$this->imageDownloader = new ImageDownloader('public/images', $this->apiKey);
|
||||
}
|
||||
|
||||
protected function executeSync(string $syncType): void
|
||||
@@ -78,27 +82,6 @@ class XbvrSyncService extends BaseSyncService
|
||||
}
|
||||
}
|
||||
|
||||
private function syncScene(array $sceneData): void
|
||||
{
|
||||
$adultVideoModel = new AdultVideo($this->pdo);
|
||||
|
||||
// Check if scene already exists by xbvr_id in metadata
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT id, metadata FROM adult_videos
|
||||
WHERE source_id = :source_id
|
||||
");
|
||||
$stmt->execute(['source_id' => $this->source['id']]);
|
||||
$existingScenes = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$existingScene = null;
|
||||
foreach ($existingScenes as $scene) {
|
||||
$metadata = json_decode($scene['metadata'], true);
|
||||
if (isset($metadata['xbvr_id']) && $metadata['xbvr_id'] === $sceneData['id']) {
|
||||
$existingScene = $scene;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function syncScene(array $sceneData): void
|
||||
{
|
||||
$adultVideoModel = new AdultVideo($this->pdo);
|
||||
@@ -124,19 +107,39 @@ class XbvrSyncService extends BaseSyncService
|
||||
$coverFilename = null;
|
||||
$screenshotFilename = null;
|
||||
|
||||
// Extract image URLs from XBVR API response
|
||||
$coverUrl = null;
|
||||
$screenshotUrl = null;
|
||||
|
||||
if (!empty($sceneData['cover_url'])) {
|
||||
$coverFilename = $this->imageDownloader->generateFilename($sceneData['cover_url'], 'cover');
|
||||
$localCoverPath = $this->imageDownloader->downloadImage($sceneData['cover_url'], $coverFilename, 'adult_videos');
|
||||
if ($localCoverPath) {
|
||||
$sceneData['local_cover_path'] = $this->imageDownloader->getPublicUrl($localCoverPath);
|
||||
}
|
||||
$coverUrl = $sceneData['cover_url'];
|
||||
$this->logProgress("Cover URL: " . $coverUrl);
|
||||
}
|
||||
|
||||
if (!empty($sceneData['screenshot_url'])) {
|
||||
$screenshotFilename = $this->imageDownloader->generateFilename($sceneData['screenshot_url'], 'screenshot');
|
||||
$localScreenshotPath = $this->imageDownloader->downloadImage($sceneData['screenshot_url'], $screenshotFilename, 'adult_videos');
|
||||
$screenshotUrl = $sceneData['screenshot_url'];
|
||||
$this->logProgress("Screenshot URL: " . $screenshotUrl);
|
||||
}
|
||||
|
||||
if (!empty($coverUrl)) {
|
||||
$coverFilename = $this->imageDownloader->generateFilename($coverUrl, 'cover');
|
||||
$localCoverPath = $this->imageDownloader->downloadImage($coverUrl, $coverFilename, 'adult_videos');
|
||||
if ($localCoverPath) {
|
||||
$sceneData['local_cover_path'] = $this->imageDownloader->getPublicUrl($localCoverPath);
|
||||
$this->logProgress("Downloaded cover: " . $localCoverPath);
|
||||
} else {
|
||||
$this->logProgress("Failed to download cover from: " . $coverUrl);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($screenshotUrl)) {
|
||||
$screenshotFilename = $this->imageDownloader->generateFilename($screenshotUrl, 'screenshot');
|
||||
$localScreenshotPath = $this->imageDownloader->downloadImage($screenshotUrl, $screenshotFilename, 'adult_videos');
|
||||
if ($localScreenshotPath) {
|
||||
$sceneData['local_screenshot_path'] = $this->imageDownloader->getPublicUrl($localScreenshotPath);
|
||||
$this->logProgress("Downloaded screenshot: " . $localScreenshotPath);
|
||||
} else {
|
||||
$this->logProgress("Failed to download screenshot from: " . $screenshotUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user