feat: add manual AniList selection for character dictionaries

This commit is contained in:
2026-04-25 15:53:20 -07:00
parent 60435fee10
commit 055bd76718
78 changed files with 1986 additions and 160 deletions

View File

@@ -129,6 +129,9 @@ test('applyInvocationsToArgs maps config and jellyfin invocation state', () => {
dictionaryTriggered: false,
dictionaryTarget: null,
dictionaryLogLevel: null,
dictionaryCandidates: false,
dictionarySelect: false,
dictionaryAnilistId: null,
statsTriggered: false,
statsBackground: false,
statsStop: false,

View File

@@ -89,6 +89,14 @@ function parseDictionaryTarget(value: string): string {
return resolved;
}
function parseDictionaryAnilistId(value: string): number {
const id = Number.parseInt(value, 10);
if (!Number.isSafeInteger(id) || id <= 0 || String(id) !== value.trim()) {
fail(`Invalid AniList media ID: ${value}`);
}
return id;
}
export function createDefaultArgs(
launcherConfig: LauncherYoutubeSubgenConfig,
mpvConfig: LauncherMpvConfig = {},
@@ -138,6 +146,8 @@ export function createDefaultArgs(
jellyfinPlay: false,
jellyfinDiscovery: false,
dictionary: false,
dictionaryCandidates: false,
dictionarySelect: false,
stats: false,
statsBackground: false,
statsStop: false,
@@ -214,6 +224,11 @@ export function applyRootOptionsToArgs(
export function applyInvocationsToArgs(parsed: Args, invocations: CliInvocations): void {
if (invocations.dictionaryTriggered) parsed.dictionary = true;
if (invocations.dictionaryCandidates) parsed.dictionaryCandidates = true;
if (invocations.dictionarySelect) parsed.dictionarySelect = true;
if (invocations.dictionaryAnilistId) {
parsed.dictionaryAnilistId = parseDictionaryAnilistId(invocations.dictionaryAnilistId);
}
if (invocations.statsTriggered) parsed.stats = true;
if (invocations.statsBackground) parsed.statsBackground = true;
if (invocations.statsStop) parsed.statsStop = true;
@@ -222,6 +237,12 @@ export function applyInvocationsToArgs(parsed: Args, invocations: CliInvocations
if (invocations.statsCleanupLifetime) parsed.statsCleanupLifetime = true;
if (invocations.dictionaryTarget) {
parsed.dictionaryTarget = parseDictionaryTarget(invocations.dictionaryTarget);
} else if (
invocations.dictionaryTriggered &&
!invocations.dictionaryCandidates &&
!invocations.dictionarySelect
) {
fail('Dictionary target path is required.');
}
if (invocations.doctorTriggered) parsed.doctor = true;
if (invocations.doctorRefreshKnownWords) parsed.doctorRefreshKnownWords = true;

View File

@@ -27,6 +27,9 @@ export interface CliInvocations {
dictionaryTriggered: boolean;
dictionaryTarget: string | null;
dictionaryLogLevel: string | null;
dictionaryCandidates: boolean;
dictionarySelect: boolean;
dictionaryAnilistId: string | null;
statsTriggered: boolean;
statsBackground: boolean;
statsStop: boolean;
@@ -136,6 +139,9 @@ export function parseCliPrograms(
let dictionaryTriggered = false;
let dictionaryTarget: string | null = null;
let dictionaryLogLevel: string | null = null;
let dictionaryCandidates = false;
let dictionarySelect = false;
let dictionaryAnilistId: string | null = null;
let statsTriggered = false;
let statsBackground = false;
let statsStop = false;
@@ -207,13 +213,18 @@ export function parseCliPrograms(
commandProgram
.command('dictionary')
.alias('dict')
.description('Generate character dictionary ZIP from a file or directory target')
.argument('<target>', 'Video file path or anime directory path')
.description('Generate or correct character dictionary AniList matches')
.argument('[target]', 'Video file path or anime directory path')
.option('--candidates', 'List AniList candidates for a character dictionary target')
.option('--select <id>', 'Pin an AniList media ID for the target series')
.option('--log-level <level>', 'Log level')
.action((target: string, options: Record<string, unknown>) => {
.action((target: string | undefined, options: Record<string, unknown>) => {
dictionaryTriggered = true;
dictionaryTarget = target;
dictionaryTarget = target ?? null;
dictionaryLogLevel = typeof options.logLevel === 'string' ? options.logLevel : null;
dictionaryCandidates = options.candidates === true;
dictionarySelect = typeof options.select === 'string';
dictionaryAnilistId = typeof options.select === 'string' ? options.select : null;
});
commandProgram
@@ -338,6 +349,9 @@ export function parseCliPrograms(
dictionaryTriggered,
dictionaryTarget,
dictionaryLogLevel,
dictionaryCandidates,
dictionarySelect,
dictionaryAnilistId,
statsTriggered,
statsBackground,
statsStop,