mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 18:22:41 -08:00
address claude comments
This commit is contained in:
@@ -344,6 +344,22 @@ export function buildRootSearchGroups(items: JellyfinItemEntry[]): JellyfinGroup
|
||||
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(
|
||||
appPath: string,
|
||||
args: Args,
|
||||
@@ -695,13 +711,11 @@ async function resolveJellyfinSelectionViaApp(
|
||||
if (!selectedChildId) fail('No Jellyfin folder/file selected.');
|
||||
const selectedChild = childById.get(selectedChildId);
|
||||
if (!selectedChild) fail('Invalid Jellyfin item selection.');
|
||||
if (isJellyfinPlayableType(selectedChild.type)) {
|
||||
return selectedChild.id;
|
||||
const selection = classifyJellyfinChildSelection(selectedChild);
|
||||
if (selection.kind === 'playable') {
|
||||
return selection.id;
|
||||
}
|
||||
if (isJellyfinContainerType(selectedChild.type)) {
|
||||
return await pickPlayableDescendants(selectedChild.id);
|
||||
}
|
||||
fail('Selected Jellyfin item is not playable.');
|
||||
currentContainerId = selection.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
readUtf8FileAppendedSince,
|
||||
parseEpisodePathFromDisplay,
|
||||
buildRootSearchGroups,
|
||||
classifyJellyfinChildSelection,
|
||||
} from './jellyfin.js';
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
const stopOnly = parseArgs(['--stop']);
|
||||
assert.equal(hasExplicitCommand(stopOnly), true);
|
||||
|
||||
@@ -245,8 +245,6 @@ export function parseArgs(argv: string[]): CliArgs {
|
||||
args.jellyfinRecursive = false;
|
||||
} else if (value === 'true' || value === '1' || value === 'yes') {
|
||||
args.jellyfinRecursive = true;
|
||||
} else {
|
||||
args.jellyfinRecursive = true;
|
||||
}
|
||||
} else if (arg === '--jellyfin-non-recursive') {
|
||||
args.jellyfinRecursive = false;
|
||||
|
||||
Reference in New Issue
Block a user