mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
yay
This commit is contained in:
@@ -127,6 +127,7 @@ class ActorController extends Controller
|
||||
LEFT JOIN tv_shows ts ON ats.tv_show_id = ts.id
|
||||
GROUP BY a.id
|
||||
ORDER BY total_media_count DESC, a.name ASC
|
||||
LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
$actors = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -243,7 +243,9 @@ class GameController extends Controller
|
||||
'playtime_desc' => 'Most Played',
|
||||
'completion_desc' => 'Highest Completion',
|
||||
'added_desc' => 'Recently Added',
|
||||
'last_played_desc' => 'Last Played'
|
||||
'last_played_desc' => 'Last Played',
|
||||
'platforms_desc' => 'Most Platforms',
|
||||
'platforms_asc' => 'Fewest Platforms'
|
||||
]
|
||||
]);
|
||||
}
|
||||
@@ -273,6 +275,7 @@ class GameController extends Controller
|
||||
$gameModel->game_key = $mainGame['game_key'];
|
||||
$platformVersions = $gameModel->getPlatformVersions();
|
||||
|
||||
|
||||
return $this->view->render($response, 'games/show.twig', [
|
||||
'title' => $mainGame['title'],
|
||||
'main_game' => $mainGame,
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Controllers;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use App\Services\PlayniteImportService;
|
||||
use App\Services\PlayniteSyncService;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class PlayniteImportController extends Controller
|
||||
@@ -133,10 +134,25 @@ class PlayniteImportController extends Controller
|
||||
$queryParams = $request->getQueryParams();
|
||||
$updateExisting = ($queryParams['update_existing'] ?? 'false') === 'true';
|
||||
|
||||
try {
|
||||
// Execute the import
|
||||
$importResult = $this->importService->importGames($previewData['games'], $updateExisting);
|
||||
// Create a source entry for Playnite if it doesn't exist
|
||||
$source = $this->getOrCreatePlayniteSource();
|
||||
|
||||
// Initialize the sync service with logging
|
||||
$syncService = new PlayniteSyncService($this->pdo, $source);
|
||||
|
||||
try {
|
||||
// Start the sync process (this will create a sync log entry)
|
||||
$syncLogId = $syncService->startSync('import');
|
||||
|
||||
// Store the sync log ID in the session so we can update it later
|
||||
$_SESSION['playnite_import']['sync_log_id'] = $syncLogId;
|
||||
|
||||
// Execute the import through the sync service
|
||||
$importResult = $syncService->importGames($previewData['games'], $updateExisting);
|
||||
|
||||
// Get the log file path to show to the user
|
||||
$logFilePath = $syncService->getLogFilePath();
|
||||
|
||||
// Clean up temp file
|
||||
if (file_exists($tempPath)) {
|
||||
unlink($tempPath);
|
||||
@@ -148,10 +164,18 @@ class PlayniteImportController extends Controller
|
||||
return $this->view->render($response, 'admin/playnite/result.twig', [
|
||||
'title' => 'Import Complete',
|
||||
'import_result' => $importResult,
|
||||
'preview_data' => $previewData
|
||||
'preview_data' => $previewData,
|
||||
'log_file' => $logFilePath,
|
||||
'sync_log_id' => $syncLogId
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Log the error
|
||||
if (isset($syncService)) {
|
||||
$syncService->logProgress("ERROR: " . $e->getMessage());
|
||||
$logFilePath = $syncService->getLogFilePath();
|
||||
}
|
||||
|
||||
// Clean up temp file
|
||||
if (file_exists($tempPath)) {
|
||||
unlink($tempPath);
|
||||
@@ -163,11 +187,44 @@ class PlayniteImportController extends Controller
|
||||
return $this->view->render($response->withStatus(500), 'admin/playnite/import.twig', [
|
||||
'title' => 'Import Playnite Games',
|
||||
'error' => 'Import failed: ' . $e->getMessage(),
|
||||
'log_file' => $logFilePath ?? null,
|
||||
'csrf_token' => $this->generateCSRFToken()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create a source for Playnite
|
||||
*/
|
||||
private function getOrCreatePlayniteSource(): array
|
||||
{
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT id, name, display_name
|
||||
FROM sources
|
||||
WHERE name = 'playnite' OR display_name = 'Playnite'
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->execute();
|
||||
|
||||
$source = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$source) {
|
||||
$stmt = $this->pdo->prepare("
|
||||
INSERT INTO sources (name, display_name, created_at, updated_at)
|
||||
VALUES ('playnite', 'Playnite', NOW(), NOW())
|
||||
");
|
||||
$stmt->execute();
|
||||
|
||||
$source = [
|
||||
'id' => $this->pdo->lastInsertId(),
|
||||
'name' => 'playnite',
|
||||
'display_name' => 'Playnite'
|
||||
];
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the import (cleanup)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user