Add targeted library selection action to plugin

This commit is contained in:
Sleeps
2026-10-07 13:44:06 +01:00
parent 7c01538571
commit c8490cf987
@@ -46,13 +46,16 @@
<h2>Indexed Libraries</h2>
<div class="fieldDescription" style="margin-bottom:1em;">
Choose which Jellyfin libraries Scene Search should keep indexed. Applying this selection removes deselected libraries from Scene Search SQLite and Meilisearch. Selection is stored in this plugin, not in the Python .env file.
Choose which Jellyfin libraries Scene Search should keep indexed. Apply selection only removes deselected libraries directly from Scene Search SQLite and Meilisearch without rebuilding the full Meilisearch index. Selection is stored in this plugin, not in the Python .env file.
</div>
<div id="libraryList">Loading libraries…</div>
<div style="margin-top:1em; margin-bottom:1em;">
<button is="emby-button" type="button" id="applyLibraries" class="raised">
<span>Apply selection only</span>
</button>
<button is="emby-button" type="button" id="indexNow" class="raised">
<span>Apply library selection / index</span>
<span>Index selected libraries</span>
</button>
<label class="checkboxContainer" style="margin-top:1em;">
<input is="emby-checkbox" type="checkbox" id="forceIndex" />
@@ -367,6 +370,45 @@
}
});
page.querySelector('#applyLibraries').addEventListener('click', function () {
var ids = selectedLibraryIds();
if (!ids.length && !window.confirm(
'No libraries are selected. This will remove all Jellyfin-backed Scene Search data from SQLite and Meilisearch. Continue?'
)) {
return;
}
page.querySelector('#indexStatus').textContent = 'Applying library selection...';
ApiClient.getPluginConfiguration(pluginId).then(function (config) {
config.SelectedLibraryIds = ids;
currentConfig = config;
return ApiClient.updatePluginConfiguration(pluginId, config);
}).then(function () {
return ApiClient.ajax({
type: 'POST',
url: ApiClient.getUrl('Plugins/SceneSearch/LibrarySelection'),
contentType: 'application/json',
data: JSON.stringify({
library_ids: ids,
force: false
})
});
}).then(function (result) {
var removedLibraries = Number(result.removed_libraries || 0);
var removedMedia = Number(result.removed_media || 0);
page.querySelector('#indexStatus').textContent = removedLibraries
? 'Selection applied: removed ' + removedLibraries +
' librar' + (removedLibraries === 1 ? 'y' : 'ies') +
' and ' + removedMedia + ' media items. No full search-index rebuild.'
: 'Selection applied: nothing to remove.';
loadLibraries();
}).catch(function () {
page.querySelector('#indexStatus').textContent =
'Could not apply library selection. Check Jellyfin logs and Scene Search API status.';
});
});
page.querySelector('#indexNow').addEventListener('click', function () {
var ids = selectedLibraryIds();
if (!ids.length && !window.confirm(