Add Jellyfin Scene Search diagnostics

This commit is contained in:
Sleeps
2026-10-07 16:03:37 +01:00
parent 7554bf0fed
commit 23bf19169e
5 changed files with 345 additions and 2 deletions
@@ -44,6 +44,19 @@
<input is="emby-input" type="number" id="timeoutSeconds" min="5" max="300" step="1" label="API Timeout (seconds)" />
</div>
<h2>Jellyfin Search Diagnostics</h2>
<div class="fieldDescription" style="margin-bottom:1em;">
Tests the exact Jellyfin integration path: provider registration, the configured Scene Search API, and Jellyfin's own search manager. This uses the currently saved plugin settings.
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="searchDiagnosticQuery" label="Test Search Query" value="scene: person standing outside" />
</div>
<button is="emby-button" type="button" id="testSearchDiagnostics" class="raised">
<span>Test Jellyfin search</span>
</button>
<div id="searchDiagnosticStatus" class="fieldDescription" style="margin-top:.75em;"></div>
<pre id="searchDiagnosticResult" style="white-space:pre-wrap;max-height:24em;overflow:auto;margin-bottom:1.5em;"></pre>
<h2>Indexed Libraries</h2>
<div class="fieldDescription" style="margin-bottom:1em;">
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.
@@ -135,6 +148,90 @@
).map(function (el) { return el.value; });
}
function runSearchDiagnostics() {
var query = page.querySelector('#searchDiagnosticQuery').value.trim();
var status = page.querySelector('#searchDiagnosticStatus');
var output = page.querySelector('#searchDiagnosticResult');
if (!query) {
status.textContent = 'Enter a test query first.';
output.textContent = '';
return;
}
status.textContent = 'Testing Jellyfin search path…';
output.textContent = '';
ApiClient.ajax({
type: 'GET',
url: ApiClient.getUrl(
'Plugins/SceneSearch/SearchDiagnostics',
{ query: query }
)
}).then(function (data) {
var providers = (data.registered_providers || []).map(function (provider) {
return provider.name + ' (' + provider.kind + ', priority ' + provider.priority + ')';
});
var lines = [
'Provider registered: ' + (data.provider_registered ? 'YES' : 'NO'),
'API configured: ' + (data.api_configured ? 'YES' : 'NO'),
'Backend query: ' + (data.backend_query || ''),
'Registered providers: ' + (providers.join(', ') || '(none)'),
'',
'Scene Search API results: ' + (data.api_result_count || 0),
'Jellyfin core results: ' + (data.core_result_count || 0),
'Resolved in Jellyfin DB: ' + (data.resolved_core_results || 0),
'API/core overlap: ' + (data.api_core_overlap || 0)
];
var apiResults = data.api_results || [];
if (apiResults.length) {
lines.push('', 'Top API results:');
apiResults.slice(0, 10).forEach(function (item) {
lines.push(
'- ' + (item.title || '(untitled)') +
' [' + (item.item_type || '?') + '] ' +
(item.item_id || '')
);
});
}
var coreResults = data.core_results || [];
if (coreResults.length) {
lines.push('', 'Top Jellyfin core results:');
coreResults.slice(0, 10).forEach(function (item) {
lines.push(
'- ' + (item.title || item.item_id || '(unknown)') +
' [' + (item.item_type || '?') + '] ' +
'score=' + Number(item.score || 0).toFixed(3) +
', resolved=' + (item.resolved ? 'yes' : 'no') +
', from API=' + (item.returned_by_api ? 'yes' : 'no')
);
});
}
output.textContent = lines.join('\n');
if (!data.provider_registered) {
status.textContent = 'Scene Search is NOT registered with Jellyfin search. Restart Jellyfin after installing/updating the plugin.';
} else if (!data.api_configured) {
status.textContent = 'The Scene Search provider is registered, but its API configuration is not valid.';
} else if (!data.api_result_count) {
status.textContent = 'Jellyfin can reach the integration, but the Scene Search API returned no grouped item results for this query.';
} else if (!data.core_result_count) {
status.textContent = 'The API returned items, but Jellyfin search returned none. Check item IDs/types and Jellyfin server logs.';
} else if (!data.resolved_core_results) {
status.textContent = 'Jellyfin received candidate IDs, but none resolve to current library items. Re-index the affected Jellyfin libraries.';
} else {
status.textContent = 'The Scene Search provider is registered and Jellyfin core is returning resolvable matches.';
}
}).catch(function (error) {
status.textContent = 'Search diagnostic failed. Check the Jellyfin server log.';
output.textContent = error && error.message ? error.message : '';
});
}
function renderLibraries(data) {
var container = page.querySelector('#libraryList');
var selected = new Set((currentConfig && currentConfig.SelectedLibraryIds) || []);
@@ -510,6 +607,8 @@
}
});
page.querySelector('#testSearchDiagnostics').addEventListener('click', runSearchDiagnostics);
page.querySelector('#reportFailed').addEventListener('click', function () {
loadIndexReport('failed', false);
});