mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 00:11:27 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
53
src/main/runtime/jellyfin-cli-play.ts
Normal file
53
src/main/runtime/jellyfin-cli-play.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import type { CliArgs } from '../../cli/args';
|
||||
|
||||
type JellyfinSession = {
|
||||
serverUrl: string;
|
||||
accessToken: string;
|
||||
userId: string;
|
||||
username: string;
|
||||
};
|
||||
|
||||
type JellyfinClientInfo = {
|
||||
clientName: string;
|
||||
clientVersion: string;
|
||||
deviceId: string;
|
||||
};
|
||||
|
||||
export function createHandleJellyfinPlayCommand(deps: {
|
||||
playJellyfinItemInMpv: (params: {
|
||||
session: JellyfinSession;
|
||||
clientInfo: JellyfinClientInfo;
|
||||
jellyfinConfig: unknown;
|
||||
itemId: string;
|
||||
audioStreamIndex?: number;
|
||||
subtitleStreamIndex?: number;
|
||||
setQuitOnDisconnectArm?: boolean;
|
||||
}) => Promise<void>;
|
||||
logWarn: (message: string) => void;
|
||||
}) {
|
||||
return async (params: {
|
||||
args: CliArgs;
|
||||
session: JellyfinSession;
|
||||
clientInfo: JellyfinClientInfo;
|
||||
jellyfinConfig: unknown;
|
||||
}): Promise<boolean> => {
|
||||
const { args, session, clientInfo, jellyfinConfig } = params;
|
||||
if (!args.jellyfinPlay) {
|
||||
return false;
|
||||
}
|
||||
if (!args.jellyfinItemId) {
|
||||
deps.logWarn('Ignoring --jellyfin-play without --jellyfin-item-id.');
|
||||
return true;
|
||||
}
|
||||
await deps.playJellyfinItemInMpv({
|
||||
session,
|
||||
clientInfo,
|
||||
jellyfinConfig,
|
||||
itemId: args.jellyfinItemId,
|
||||
audioStreamIndex: args.jellyfinAudioStreamIndex,
|
||||
subtitleStreamIndex: args.jellyfinSubtitleStreamIndex,
|
||||
setQuitOnDisconnectArm: true,
|
||||
});
|
||||
return true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user