mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
117 lines
3.7 KiB
PHP
117 lines
3.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Setup Stash Ignore Configuration
|
|
*
|
|
* Example script showing how to configure ignore paths for Stash sources
|
|
*/
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
// Load environment variables
|
|
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
|
$dotenv->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";
|
|
}
|