basic filter D:

This commit is contained in:
Lars Behrends
2025-10-24 17:12:36 +02:00
parent 218d0c28c0
commit e78c073f21
13 changed files with 1811 additions and 1120 deletions

View File

@@ -75,6 +75,7 @@ class PlayniteImportService
*/
private function transformPlayniteGame(array $game, int $index): array
{
/*
// Validate required fields
if (empty($game['Name'])) {
throw new \Exception("Missing game name");
@@ -83,7 +84,7 @@ class PlayniteImportService
if (empty($game['GameId'])) {
throw new \Exception("Missing GameId");
}
*/
// Find or create source
$source = $this->findOrCreateSource($game);
@@ -132,10 +133,10 @@ class PlayniteImportService
'steam_app_id' => $this->extractSteamAppId($game),
// Playnite-specific metadata
'is_installed' => $game['IsInstalled'] ?? false,
'is_favorite' => $game['Favorite'] ?? false,
'is_custom_game' => $game['IsCustomGame'] ?? false,
'installation_status' => $game['InstallationStatus'] ?? 0,
// 'is_installed' => $this->toBoolean($game['IsInstalled'] ?? false),
//'is_favorite' => $this->toBoolean($game['Favorite'] ?? false),
//'is_custom_game' => $this->toBoolean($game['IsCustomGame'] ?? false),
//'installation_status' => $game['InstallationStatus'] ?? 0,
// Timestamps
'added_at' => isset($game['Added']) ? date('Y-m-d H:i:s', strtotime($game['Added'])) : null,
@@ -147,20 +148,20 @@ class PlayniteImportService
'metadata' => json_encode([
'playnite_id' => $game['Id'] ?? null,
'version' => $game['Version'] ?? null,
'hidden' => $game['Hidden'] ?? false,
'hidden' => $this->toBoolean($game['Hidden'] ?? false),
'notes' => $game['Notes'] ?? null,
'manual' => $game['Manual'] ?? null,
'pre_script' => $game['PreScript'] ?? null,
'post_script' => $game['PostScript'] ?? null,
'game_started_script' => $game['GameStartedScript'] ?? null,
'use_global_scripts' => [
'pre' => $game['UseGlobalPreScript'] ?? true,
'post' => $game['UseGlobalPostScript'] ?? true,
'game_started' => $game['UseGlobalGameStartedScript'] ?? true
'pre' => $this->toBoolean($game['UseGlobalPreScript'] ?? true),
'post' => $this->toBoolean($game['UseGlobalPostScript'] ?? true),
'game_started' => $this->toBoolean($game['UseGlobalGameStartedScript'] ?? true)
]
])
];
return $transformed;
}
@@ -371,4 +372,21 @@ class PlayniteImportService
$gameModel = new Game($this->pdo);
$gameModel->update($gameId, $gameData);
}
/**
* Convert a value to boolean, handling empty strings properly
*/
private function toBoolean($value): bool
{
if ($value === null || $value === false || $value === 0 || $value === '0') {
return false;
}
if ($value === true || $value === 1 || $value === '1') {
return true;
}
if (is_string($value)) {
return !empty(trim($value));
}
return (bool) $value;
}
}