mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-02 06:22:42 -08:00
address claude comments
This commit is contained in:
@@ -344,6 +344,22 @@ export function buildRootSearchGroups(items: JellyfinItemEntry[]): JellyfinGroup
|
|||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type JellyfinChildSelection =
|
||||||
|
| { kind: 'playable'; id: string }
|
||||||
|
| { kind: 'container'; id: string };
|
||||||
|
|
||||||
|
export function classifyJellyfinChildSelection(
|
||||||
|
selectedChild: Pick<JellyfinGroupEntry, 'id' | 'type'>,
|
||||||
|
): JellyfinChildSelection {
|
||||||
|
if (isJellyfinPlayableType(selectedChild.type)) {
|
||||||
|
return { kind: 'playable', id: selectedChild.id };
|
||||||
|
}
|
||||||
|
if (isJellyfinContainerType(selectedChild.type)) {
|
||||||
|
return { kind: 'container', id: selectedChild.id };
|
||||||
|
}
|
||||||
|
fail('Selected Jellyfin item is not playable.');
|
||||||
|
}
|
||||||
|
|
||||||
async function runAppJellyfinListCommand(
|
async function runAppJellyfinListCommand(
|
||||||
appPath: string,
|
appPath: string,
|
||||||
args: Args,
|
args: Args,
|
||||||
@@ -695,13 +711,11 @@ async function resolveJellyfinSelectionViaApp(
|
|||||||
if (!selectedChildId) fail('No Jellyfin folder/file selected.');
|
if (!selectedChildId) fail('No Jellyfin folder/file selected.');
|
||||||
const selectedChild = childById.get(selectedChildId);
|
const selectedChild = childById.get(selectedChildId);
|
||||||
if (!selectedChild) fail('Invalid Jellyfin item selection.');
|
if (!selectedChild) fail('Invalid Jellyfin item selection.');
|
||||||
if (isJellyfinPlayableType(selectedChild.type)) {
|
const selection = classifyJellyfinChildSelection(selectedChild);
|
||||||
return selectedChild.id;
|
if (selection.kind === 'playable') {
|
||||||
|
return selection.id;
|
||||||
}
|
}
|
||||||
if (isJellyfinContainerType(selectedChild.type)) {
|
currentContainerId = selection.id;
|
||||||
return await pickPlayableDescendants(selectedChild.id);
|
|
||||||
}
|
|
||||||
fail('Selected Jellyfin item is not playable.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
readUtf8FileAppendedSince,
|
readUtf8FileAppendedSince,
|
||||||
parseEpisodePathFromDisplay,
|
parseEpisodePathFromDisplay,
|
||||||
buildRootSearchGroups,
|
buildRootSearchGroups,
|
||||||
|
classifyJellyfinChildSelection,
|
||||||
} from './jellyfin.js';
|
} from './jellyfin.js';
|
||||||
|
|
||||||
type RunResult = {
|
type RunResult = {
|
||||||
@@ -443,3 +444,11 @@ test('buildRootSearchGroups excludes episodes and keeps containers/movies', () =
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('classifyJellyfinChildSelection keeps container drilldown state instead of flattening', () => {
|
||||||
|
const next = classifyJellyfinChildSelection({ id: 'season-2', type: 'Season' });
|
||||||
|
assert.deepEqual(next, {
|
||||||
|
kind: 'container',
|
||||||
|
id: 'season-2',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ test('parseArgs handles space-separated jellyfin recursive control', () => {
|
|||||||
assert.equal(args.jellyfinRecursive, false);
|
assert.equal(args.jellyfinRecursive, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parseArgs ignores unrecognized space-separated jellyfin recursive values', () => {
|
||||||
|
const args = parseArgs(['--jellyfin-items', '--jellyfin-recursive', '--start']);
|
||||||
|
assert.equal(args.jellyfinRecursive, undefined);
|
||||||
|
assert.equal(args.start, true);
|
||||||
|
});
|
||||||
|
|
||||||
test('hasExplicitCommand and shouldStartApp preserve command intent', () => {
|
test('hasExplicitCommand and shouldStartApp preserve command intent', () => {
|
||||||
const stopOnly = parseArgs(['--stop']);
|
const stopOnly = parseArgs(['--stop']);
|
||||||
assert.equal(hasExplicitCommand(stopOnly), true);
|
assert.equal(hasExplicitCommand(stopOnly), true);
|
||||||
|
|||||||
@@ -245,8 +245,6 @@ export function parseArgs(argv: string[]): CliArgs {
|
|||||||
args.jellyfinRecursive = false;
|
args.jellyfinRecursive = false;
|
||||||
} else if (value === 'true' || value === '1' || value === 'yes') {
|
} else if (value === 'true' || value === '1' || value === 'yes') {
|
||||||
args.jellyfinRecursive = true;
|
args.jellyfinRecursive = true;
|
||||||
} else {
|
|
||||||
args.jellyfinRecursive = true;
|
|
||||||
}
|
}
|
||||||
} else if (arg === '--jellyfin-non-recursive') {
|
} else if (arg === '--jellyfin-non-recursive') {
|
||||||
args.jellyfinRecursive = false;
|
args.jellyfinRecursive = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user