mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-23 00:11:28 -07:00
114 lines
3.3 KiB
TypeScript
114 lines
3.3 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import type { LauncherCommandContext } from './context.js';
|
|
import { runPlaybackCommandWithDeps } from './playback-command.js';
|
|
|
|
function createContext(): LauncherCommandContext {
|
|
return {
|
|
args: {
|
|
backend: 'auto',
|
|
directory: '.',
|
|
recursive: false,
|
|
profile: '',
|
|
startOverlay: false,
|
|
youtubeMode: 'download',
|
|
whisperBin: '',
|
|
whisperModel: '',
|
|
whisperVadModel: '',
|
|
whisperThreads: 0,
|
|
youtubeSubgenOutDir: '',
|
|
youtubeSubgenAudioFormat: '',
|
|
youtubeSubgenKeepTemp: false,
|
|
youtubeFixWithAi: false,
|
|
youtubePrimarySubLangs: [],
|
|
youtubeSecondarySubLangs: [],
|
|
youtubeAudioLangs: [],
|
|
youtubeWhisperSourceLanguage: '',
|
|
aiConfig: {},
|
|
useTexthooker: false,
|
|
autoStartOverlay: false,
|
|
texthookerOnly: false,
|
|
useRofi: false,
|
|
logLevel: 'info',
|
|
passwordStore: '',
|
|
target: 'https://www.youtube.com/watch?v=65Ovd7t8sNw',
|
|
targetKind: 'url',
|
|
jimakuApiKey: '',
|
|
jimakuApiKeyCommand: '',
|
|
jimakuApiBaseUrl: '',
|
|
jimakuLanguagePreference: 'ja',
|
|
jimakuMaxEntryResults: 20,
|
|
jellyfin: false,
|
|
jellyfinLogin: false,
|
|
jellyfinLogout: false,
|
|
jellyfinPlay: false,
|
|
jellyfinDiscovery: false,
|
|
dictionary: false,
|
|
stats: false,
|
|
doctor: false,
|
|
doctorRefreshKnownWords: false,
|
|
configPath: false,
|
|
configShow: false,
|
|
mpvIdle: false,
|
|
mpvSocket: false,
|
|
mpvStatus: false,
|
|
mpvArgs: '',
|
|
appPassthrough: false,
|
|
appArgs: [],
|
|
jellyfinServer: '',
|
|
jellyfinUsername: '',
|
|
jellyfinPassword: '',
|
|
},
|
|
scriptPath: '/tmp/subminer',
|
|
scriptName: 'subminer',
|
|
mpvSocketPath: '/tmp/subminer.sock',
|
|
pluginRuntimeConfig: {
|
|
socketPath: '/tmp/subminer.sock',
|
|
autoStart: true,
|
|
autoStartVisibleOverlay: true,
|
|
autoStartPauseUntilReady: true,
|
|
},
|
|
appPath: '/tmp/SubMiner.AppImage',
|
|
launcherJellyfinConfig: {},
|
|
processAdapter: {
|
|
platform: () => 'linux',
|
|
onSignal: () => {},
|
|
writeStdout: () => {},
|
|
exit: (_code: number): never => {
|
|
throw new Error('unexpected exit');
|
|
},
|
|
setExitCode: () => {},
|
|
},
|
|
};
|
|
}
|
|
|
|
test('youtube playback launches overlay with youtube-play args in the primary app start', async () => {
|
|
const calls: string[] = [];
|
|
const context = createContext();
|
|
|
|
await runPlaybackCommandWithDeps(context, {
|
|
ensurePlaybackSetupReady: async () => {},
|
|
chooseTarget: async (_args, _scriptPath) => ({ target: context.args.target, kind: 'url' }),
|
|
checkDependencies: () => {},
|
|
registerCleanup: () => {},
|
|
startMpv: async () => {
|
|
calls.push('startMpv');
|
|
},
|
|
waitForUnixSocketReady: async () => true,
|
|
startOverlay: async (_appPath, _args, _socketPath, extraAppArgs = []) => {
|
|
calls.push(`startOverlay:${extraAppArgs.join(' ')}`);
|
|
},
|
|
launchAppCommandDetached: (_appPath: string, appArgs: string[]) => {
|
|
calls.push(`launch:${appArgs.join(' ')}`);
|
|
},
|
|
log: () => {},
|
|
cleanupPlaybackSession: async () => {},
|
|
getMpvProc: () => null,
|
|
});
|
|
|
|
assert.deepEqual(calls, [
|
|
'startMpv',
|
|
'startOverlay:--youtube-play https://www.youtube.com/watch?v=65Ovd7t8sNw --youtube-mode download',
|
|
]);
|
|
});
|