mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
fix(jellyfin): make terminal play work with a running app and report progress (#288)
This commit is contained in:
1 parent
78eca52b7e
commit
78a9b6346f
33 files changed
+934
-924
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
// Structured replies the app writes to `--jellyfin-response-path`. The launcher passes a temp
|
||||
// path and waits for the file instead of scraping logs, because the command usually runs in an
|
||||
// already-running app instance whose output never reaches the launcher's helper process.
|
||||
|
||||
export type JellyfinCliLibrary = {
|
||||
id: string;
|
||||
name: string;
|
||||
collectionType: string;
|
||||
};
|
||||
|
||||
export type JellyfinCliItem = {
|
||||
id: string;
|
||||
title: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type JellyfinPreviewAuthPayload = {
|
||||
serverUrl: string;
|
||||
accessToken: string;
|
||||
userId: string;
|
||||
};
|
||||
|
||||
export type JellyfinCliResponse =
|
||||
| { libraries: JellyfinCliLibrary[] }
|
||||
| { items: JellyfinCliItem[] }
|
||||
| { error: string }
|
||||
| JellyfinPreviewAuthPayload;
|
||||
|
||||
// Writes via rename so a polling reader never parses a half-written file.
|
||||
export function writeJellyfinCliResponse(
|
||||
responsePath: string,
|
||||
response: JellyfinCliResponse,
|
||||
): void {
|
||||
fs.mkdirSync(path.dirname(responsePath), { recursive: true });
|
||||
const tempPath = `${responsePath}.${process.pid}.tmp`;
|
||||
fs.writeFileSync(tempPath, JSON.stringify(response), 'utf-8');
|
||||
fs.renameSync(tempPath, responsePath);
|
||||
}
|
||||
Reference in new issue
Block a user