actor sync

This commit is contained in:
Lars Behrends
2025-11-06 13:08:02 +01:00
parent 3f56625205
commit a44c311e89
14 changed files with 773 additions and 9 deletions

View File

@@ -85,6 +85,28 @@
Cleanup
</button>
</div>
{% elseif source.name == 'stash' %}
<!-- Stash-specific sync options -->
<div class="d-flex gap-2 mb-2">
<button onclick="startSync({{ source.id }}, 'full')"
class="btn btn-primary btn-sm flex-fill"
data-source-id="{{ source.id }}">
Full Sync
</button>
<button onclick="startSync({{ source.id }}, 'incremental')"
class="btn btn-secondary btn-sm flex-fill"
data-source-id="{{ source.id }}">
Incremental
</button>
</div>
<!-- Stash Performer Sync Button -->
<div class="mb-2">
<button onclick="syncStashPerformers()"
class="btn btn-info btn-sm w-100"
id="stash-performer-sync-btn">
<i class="bi bi-person-lines-fill me-1"></i>Sync Performers
</button>
</div>
{% else %}
<!-- Standard sync options for other sources -->
<div class="d-flex gap-2 mb-2">
@@ -487,6 +509,43 @@
}
}
function syncStashPerformers() {
const button = document.getElementById('stash-performer-sync-btn');
const originalText = button.innerHTML;
// Show loading state
button.disabled = true;
button.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>Syncing...';
// Make AJAX request to sync performers
fetch('/api/actors/sync-existing-stash', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert(`Stash performer sync completed!\n\nProcessed: ${data.results.processed}\nUpdated: ${data.results.updated}\nSkipped: ${data.results.skipped}\nNot found in Stash: ${data.results.not_found_in_stash.length}\n\nCheck the logs for detailed information.`);
} else {
alert('Error syncing performers: ' + (data.error || 'Unknown error'));
}
// Re-enable button
button.disabled = false;
button.innerHTML = originalText;
})
.catch(error => {
alert('Failed to sync performers: ' + error.message);
// Re-enable button
button.disabled = false;
button.innerHTML = originalText;
});
}
// Cleanup intervals on page unload
window.addEventListener('beforeunload', () => {
Object.values(syncIntervals).forEach(interval => clearInterval(interval));

View File

@@ -63,9 +63,9 @@
<h5 class="mt-3" id="syncStatus">Idle</h5>
<p class="text-muted mb-0">Last sync: <span id="lastSyncTime">Never</span></p>
</div>
<hr>
<div class="mb-3">
<div class="d-flex justify-content-between mb-1">
<span>Movies</span>
@@ -75,7 +75,7 @@
<div id="movieProgress" class="progress-bar bg-success" role="progressbar" style="width: 0%"></div>
</div>
</div>
<div class="mb-3">
<div class="d-flex justify-content-between mb-1">
<span>TV Shows</span>
@@ -85,7 +85,7 @@
<div id="tvShowProgress" class="progress-bar bg-info" role="progressbar" style="width: 0%"></div>
</div>
</div>
<div class="mb-3">
<div class="d-flex justify-content-between mb-1">
<span>Music</span>
@@ -95,6 +95,16 @@
<div id="musicProgress" class="progress-bar bg-warning" role="progressbar" style="width: 0%"></div>
</div>
</div>
<div class="mb-3">
<div class="d-flex justify-content-between mb-1">
<span>Adult Videos</span>
<span id="adultVideoCount">0</span>
</div>
<div class="progress" style="height: 5px;">
<div id="adultVideoProgress" class="progress-bar bg-danger" role="progressbar" style="width: 0%"></div>
</div>
</div>
</div>
</div>
@@ -107,6 +117,9 @@
<span><i class="bi bi-search me-2"></i> Scan Libraries</span>
<span class="badge bg-primary rounded-pill" id="pendingScans">0</span>
</button>
<button class="list-group-item list-group-item-action" id="syncStashPerformers">
<i class="bi bi-person-lines-fill me-2"></i> Sync Stash Performers
</button>
<button class="list-group-item list-group-item-action">
<i class="bi bi-arrow-clockwise me-2"></i> Update Metadata
</button>
@@ -248,6 +261,13 @@
$('#scanLibraries').click(function() {
startSync('scan');
});
// Handle sync Stash performers
$('#syncStashPerformers').click(function() {
if (confirm('Are you sure you want to sync existing performers with Stash? This will update your local performer data with information from Stash.')) {
syncStashPerformers();
}
});
// Handle cancel sync
$('#cancelSync').click(function() {
@@ -294,6 +314,35 @@
});
}
// Function to sync Stash performers
function syncStashPerformers() {
// Show loading state
$('#syncStashPerformers').prop('disabled', true).html('<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>Syncing...');
// Make AJAX request to sync performers
$.post('/api/actors/sync-existing-stash', function(response) {
if (response.success) {
addLog('Stash performer sync completed successfully', 'success');
addLog('Processed: ' + response.results.processed + ', Updated: ' + response.results.updated + ', Skipped: ' + response.results.skipped, 'info');
if (response.results.not_found_in_stash && response.results.not_found_in_stash.length > 0) {
addLog('Found ' + response.results.not_found_in_stash.length + ' performers not in Stash - check reports', 'warning');
}
if (response.results.errors && response.results.errors.length > 0) {
addLog('Encountered ' + response.results.errors.length + ' errors during sync', 'error');
}
} else {
addLog('Error syncing performers: ' + (response.error || 'Unknown error'), 'error');
}
$('#syncStashPerformers').prop('disabled', false).html('<i class="bi bi-person-lines-fill me-2"></i> Sync Stash Performers');
}).fail(function(xhr, status, error) {
addLog('Failed to sync performers: ' + error, 'error');
$('#syncStashPerformers').prop('disabled', false).html('<i class="bi bi-person-lines-fill me-2"></i> Sync Stash Performers');
});
}
// Function to cancel sync
function cancelSync() {
$.post('{{ path_for("admin.sync.cancel") }}', function(response) {