load(); // Load database configuration $dbConfig = require __DIR__ . '/config/database.php'; \App\Database\Database::setConfig($dbConfig); // Initialize database try { $pdo = \App\Database\Database::getInstance(); echo "āœ… Database connection successful\n"; // Get Stash source $stmt = $pdo->prepare('SELECT * FROM sources WHERE name = ?'); $stmt->execute(['stash']); $stashSource = $stmt->fetch(PDO::FETCH_ASSOC); if (!$stashSource) { echo "āŒ No Stash source found in database\n"; echo "šŸ’” Please set up a Stash source first\n"; exit(1); } echo "šŸ” Current Stash source configuration:\n"; echo " ID: {$stashSource['id']}\n"; echo " Name: {$stashSource['display_name']}\n"; echo " Current config: " . ($stashSource['config'] ?: 'NOT SET') . "\n\n"; // Example ignore configurations $exampleConfigs = [ 'ignore_sample_videos' => [ 'ignore_paths' => ['sample', 'trailer'] ], 'ignore_specific_directories' => [ 'ignore_paths' => ['/media/videos/ignored/', '/media/videos/temp/'] ], 'ignore_multiple_patterns' => [ 'ignore_paths' => ['sample', 'trailer', 'temp', 'backup'] ] ]; echo "šŸ“‹ Example ignore configurations:\n\n"; foreach ($exampleConfigs as $name => $config) { echo "Configuration: {$name}\n"; echo " JSON: " . json_encode($config) . "\n"; echo " Description: Ignores scenes where any file path contains: " . implode(', ', $config['ignore_paths']) . "\n\n"; } // Ask user which config to apply echo "Choose a configuration to apply:\n"; echo "1. Ignore sample and trailer videos\n"; echo "2. Ignore specific directories\n"; echo "3. Ignore multiple patterns\n"; echo "4. Custom configuration\n"; echo "Enter choice (1-4): "; $choice = trim(fgets(STDIN)); $selectedConfig = null; switch ($choice) { case '1': $selectedConfig = $exampleConfigs['ignore_sample_videos']; break; case '2': $selectedConfig = $exampleConfigs['ignore_specific_directories']; break; case '3': $selectedConfig = $exampleConfigs['ignore_multiple_patterns']; break; case '4': echo "Enter custom ignore patterns (comma-separated): "; $patterns = trim(fgets(STDIN)); $patternArray = array_map('trim', explode(',', $patterns)); $selectedConfig = ['ignore_paths' => $patternArray]; break; default: echo "āŒ Invalid choice\n"; exit(1); } // Update the source config $newConfigJson = json_encode($selectedConfig); $stmt = $pdo->prepare('UPDATE sources SET config = ? WHERE id = ?'); $result = $stmt->execute([$newConfigJson, $stashSource['id']]); if ($result) { echo "\nāœ… Successfully updated Stash source configuration!\n"; echo " New config: {$newConfigJson}\n"; echo "\nšŸ“ The Stash sync will now ignore scenes where any file path contains:\n"; foreach ($selectedConfig['ignore_paths'] as $pattern) { echo " - '{$pattern}'\n"; } echo "\nšŸ”„ Run a Stash sync to test the ignore functionality.\n"; } else { echo "āŒ Failed to update configuration\n"; } } catch (Exception $e) { echo "āŒ Error: " . $e->getMessage() . "\n"; echo " File: " . $e->getFile() . ":" . $e->getLine() . "\n"; }