mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
[codex] Fix Jellyfin setup and discovery toggle (#59)
This commit is contained in:
@@ -117,6 +117,7 @@ export const INTEGRATIONS_DEFAULT_CONFIG: Pick<
|
||||
jellyfin: {
|
||||
enabled: false,
|
||||
serverUrl: '',
|
||||
recentServers: [],
|
||||
username: '',
|
||||
deviceId: 'subminer',
|
||||
clientName: 'SubMiner',
|
||||
|
||||
@@ -265,6 +265,12 @@ export function buildIntegrationConfigOptionRegistry(
|
||||
defaultValue: defaultConfig.jellyfin.serverUrl,
|
||||
description: 'Base Jellyfin server URL (for example: http://localhost:8096).',
|
||||
},
|
||||
{
|
||||
path: 'jellyfin.recentServers',
|
||||
kind: 'array',
|
||||
defaultValue: defaultConfig.jellyfin.recentServers,
|
||||
description: 'Recently authenticated Jellyfin server URLs shown in setup.',
|
||||
},
|
||||
{
|
||||
path: 'jellyfin.username',
|
||||
kind: 'string',
|
||||
|
||||
@@ -318,6 +318,26 @@ export function applyIntegrationConfig(context: ResolveContext): void {
|
||||
'Expected string array.',
|
||||
);
|
||||
}
|
||||
|
||||
if (Array.isArray(src.jellyfin.recentServers)) {
|
||||
const seenRecentServers = new Set<string>();
|
||||
resolved.jellyfin.recentServers = src.jellyfin.recentServers
|
||||
.filter((item): item is string => typeof item === 'string')
|
||||
.map((item) => item.trim().replace(/\/+$/, ''))
|
||||
.filter((item) => {
|
||||
if (!item || seenRecentServers.has(item)) return false;
|
||||
seenRecentServers.add(item);
|
||||
return true;
|
||||
})
|
||||
.slice(0, 5);
|
||||
} else if (src.jellyfin.recentServers !== undefined) {
|
||||
warn(
|
||||
'jellyfin.recentServers',
|
||||
src.jellyfin.recentServers,
|
||||
resolved.jellyfin.recentServers,
|
||||
'Expected string array.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isObject(src.discordPresence)) {
|
||||
|
||||
@@ -17,6 +17,34 @@ test('jellyfin directPlayContainers are normalized', () => {
|
||||
assert.deepEqual(context.resolved.jellyfin.directPlayContainers, ['mkv', 'mp4', 'webm']);
|
||||
});
|
||||
|
||||
test('jellyfin recentServers are normalized, deduped, and capped', () => {
|
||||
const { context } = createResolveContext({
|
||||
jellyfin: {
|
||||
recentServers: [
|
||||
' http://one.local:8096/ ',
|
||||
'',
|
||||
'http://two.local:8096',
|
||||
'http://one.local:8096',
|
||||
42 as unknown as string,
|
||||
'http://three.local:8096',
|
||||
'http://four.local:8096',
|
||||
'http://five.local:8096',
|
||||
'http://six.local:8096',
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
applyIntegrationConfig(context);
|
||||
|
||||
assert.deepEqual(context.resolved.jellyfin.recentServers, [
|
||||
'http://one.local:8096',
|
||||
'http://two.local:8096',
|
||||
'http://three.local:8096',
|
||||
'http://four.local:8096',
|
||||
'http://five.local:8096',
|
||||
]);
|
||||
});
|
||||
|
||||
test('jellyfin legacy auth keys are ignored by resolver', () => {
|
||||
const { context } = createResolveContext({
|
||||
jellyfin: { accessToken: 'legacy-token', userId: 'legacy-user' } as unknown as never,
|
||||
|
||||
Reference in New Issue
Block a user