diff --git a/src/core/services/cli-command.test.ts b/src/core/services/cli-command.test.ts index 3935d24..7370c7a 100644 --- a/src/core/services/cli-command.test.ts +++ b/src/core/services/cli-command.test.ts @@ -39,6 +39,7 @@ function makeArgs(overrides: Partial = {}): CliArgs { jellyfinSubtitleUrlsOnly: false, jellyfinPlay: false, jellyfinRemoteAnnounce: false, + jellyfinPreviewAuth: false, texthooker: false, help: false, autoStartOverlay: false, diff --git a/src/core/services/startup-bootstrap.test.ts b/src/core/services/startup-bootstrap.test.ts index dff7c40..3372d79 100644 --- a/src/core/services/startup-bootstrap.test.ts +++ b/src/core/services/startup-bootstrap.test.ts @@ -39,6 +39,7 @@ function makeArgs(overrides: Partial = {}): CliArgs { jellyfinSubtitleUrlsOnly: false, jellyfinPlay: false, jellyfinRemoteAnnounce: false, + jellyfinPreviewAuth: false, texthooker: false, help: false, autoStartOverlay: false, diff --git a/src/main.ts b/src/main.ts index c9b34a8..89ef363 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1498,6 +1498,10 @@ const { listJellyfinItemsRuntime(session, clientInfo, params), listJellyfinSubtitleTracks: (session, clientInfo, itemId) => listJellyfinSubtitleTracksRuntime(session, clientInfo, itemId), + writeJellyfinPreviewAuth: (responsePath, payload) => { + fs.mkdirSync(path.dirname(responsePath), { recursive: true }); + fs.writeFileSync(responsePath, JSON.stringify(payload, null, 2), 'utf-8'); + }, logInfo: (message) => logger.info(message), }, handleJellyfinPlayCommandMainDeps: { diff --git a/src/main/runtime/composers/jellyfin-runtime-composer.test.ts b/src/main/runtime/composers/jellyfin-runtime-composer.test.ts index 193c2f9..ed68a1d 100644 --- a/src/main/runtime/composers/jellyfin-runtime-composer.test.ts +++ b/src/main/runtime/composers/jellyfin-runtime-composer.test.ts @@ -111,6 +111,7 @@ test('composeJellyfinRuntimeHandlers returns callable jellyfin runtime handlers' listJellyfinLibraries: async () => [], listJellyfinItems: async () => [], listJellyfinSubtitleTracks: async () => [], + writeJellyfinPreviewAuth: () => {}, logInfo: () => {}, }, handleJellyfinPlayCommandMainDeps: { diff --git a/src/main/runtime/jellyfin-cli-main-deps.test.ts b/src/main/runtime/jellyfin-cli-main-deps.test.ts index 66f8b08..780c5a0 100644 --- a/src/main/runtime/jellyfin-cli-main-deps.test.ts +++ b/src/main/runtime/jellyfin-cli-main-deps.test.ts @@ -31,6 +31,10 @@ test('jellyfin auth commands main deps builder maps callbacks', async () => { test('jellyfin list commands main deps builder maps callbacks', async () => { const calls: string[] = []; + const writes: Array<{ + responsePath: string; + payload: { serverUrl: string; accessToken: string; userId: string }; + }> = []; const deps = createBuildHandleJellyfinListCommandsMainDepsHandler({ listJellyfinLibraries: async () => { calls.push('libraries'); @@ -44,14 +48,32 @@ test('jellyfin list commands main deps builder maps callbacks', async () => { calls.push('subtitles'); return []; }, + writeJellyfinPreviewAuth: (responsePath, payload) => { + writes.push({ responsePath, payload }); + }, logInfo: (message) => calls.push(`info:${message}`), })(); await deps.listJellyfinLibraries({} as never, {} as never); await deps.listJellyfinItems({} as never, {} as never, { libraryId: '', limit: 1 }); await deps.listJellyfinSubtitleTracks({} as never, {} as never, 'id'); + deps.writeJellyfinPreviewAuth('/tmp/jellyfin-preview.json', { + serverUrl: 'https://example.test', + accessToken: 'token', + userId: 'user-id', + }); deps.logInfo('done'); assert.deepEqual(calls, ['libraries', 'items', 'subtitles', 'info:done']); + assert.deepEqual(writes, [ + { + responsePath: '/tmp/jellyfin-preview.json', + payload: { + serverUrl: 'https://example.test', + accessToken: 'token', + userId: 'user-id', + }, + }, + ]); }); test('jellyfin play command main deps builder maps callbacks', async () => { diff --git a/src/main/runtime/jellyfin-cli-main-deps.ts b/src/main/runtime/jellyfin-cli-main-deps.ts index 5f85d97..d0e163f 100644 --- a/src/main/runtime/jellyfin-cli-main-deps.ts +++ b/src/main/runtime/jellyfin-cli-main-deps.ts @@ -32,6 +32,8 @@ export function createBuildHandleJellyfinListCommandsMainDepsHandler( deps.listJellyfinItems(session, clientInfo, params), listJellyfinSubtitleTracks: (session, clientInfo, itemId) => deps.listJellyfinSubtitleTracks(session, clientInfo, itemId), + writeJellyfinPreviewAuth: (responsePath, payload) => + deps.writeJellyfinPreviewAuth(responsePath, payload), logInfo: (message: string) => deps.logInfo(message), }); }