mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 20:12:54 -07:00
[codex] Fix Jellyfin setup and discovery toggle (#59)
This commit is contained in:
@@ -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