mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 06:22:44 -08:00
refactor: split main runtime flows into focused modules
This commit is contained in:
35
src/main/runtime/jellyfin-cli-remote-announce.ts
Normal file
35
src/main/runtime/jellyfin-cli-remote-announce.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { CliArgs } from '../../cli/args';
|
||||
|
||||
type JellyfinRemoteSession = {
|
||||
advertiseNow: () => Promise<boolean>;
|
||||
};
|
||||
|
||||
export function createHandleJellyfinRemoteAnnounceCommand(deps: {
|
||||
startJellyfinRemoteSession: () => Promise<void>;
|
||||
getRemoteSession: () => JellyfinRemoteSession | null;
|
||||
logInfo: (message: string) => void;
|
||||
logWarn: (message: string) => void;
|
||||
}) {
|
||||
return async (args: CliArgs): Promise<boolean> => {
|
||||
if (!args.jellyfinRemoteAnnounce) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await deps.startJellyfinRemoteSession();
|
||||
const remoteSession = deps.getRemoteSession();
|
||||
if (!remoteSession) {
|
||||
deps.logWarn('Jellyfin remote session is not available.');
|
||||
return true;
|
||||
}
|
||||
|
||||
const visible = await remoteSession.advertiseNow();
|
||||
if (visible) {
|
||||
deps.logInfo('Jellyfin cast target is visible in server sessions.');
|
||||
} else {
|
||||
deps.logWarn(
|
||||
'Jellyfin remote announce sent, but cast target is not visible in server sessions yet.',
|
||||
);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user