mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-25 00:11:26 -07:00
refactor: remove legacy youtube launcher mode plumbing
This commit is contained in:
@@ -13,8 +13,6 @@ ${B}Session${R}
|
||||
--background Start in tray/background mode
|
||||
--start Connect to mpv and launch overlay
|
||||
--launch-mpv ${D}[targets...]${R} Launch mpv with the SubMiner mpv profile and exit
|
||||
--youtube-play ${D}URL${R} Start app-owned YouTube subtitle auto-load flow for a URL
|
||||
--youtube-mode ${D}download|generate${R} Subtitle acquisition mode for YouTube flow
|
||||
--stop Stop the running instance
|
||||
--stats Open the stats dashboard in your browser
|
||||
--texthooker Start texthooker server only ${D}(no overlay)${R}
|
||||
|
||||
@@ -54,7 +54,7 @@ test('cli command runtime handler prepares overlay prerequisites before overlay
|
||||
},
|
||||
});
|
||||
|
||||
handler({ youtubePlay: 'https://www.youtube.com/watch?v=test' } as never);
|
||||
handler({ settings: true } as never);
|
||||
|
||||
assert.deepEqual(calls, ['prereqs', 'context', 'cli:initial:ctx']);
|
||||
});
|
||||
|
||||
@@ -72,7 +72,6 @@ test('composeMpvRuntimeHandlers returns callable handlers and forwards to inject
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: null,
|
||||
youtubePlaybackFlowPending: false,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
@@ -281,7 +280,6 @@ test('composeMpvRuntimeHandlers skips MeCab warmup when all POS-dependent annota
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: null,
|
||||
youtubePlaybackFlowPending: false,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
@@ -413,7 +411,6 @@ test('composeMpvRuntimeHandlers runs tokenization warmup once across sequential
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: null,
|
||||
youtubePlaybackFlowPending: false,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
@@ -553,7 +550,6 @@ test('composeMpvRuntimeHandlers does not block first tokenization on dictionary
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: null,
|
||||
youtubePlaybackFlowPending: false,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
@@ -687,7 +683,6 @@ test('composeMpvRuntimeHandlers shows annotation loading OSD after tokenization-
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: null,
|
||||
youtubePlaybackFlowPending: false,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
@@ -835,7 +830,6 @@ test('composeMpvRuntimeHandlers reuses completed background tokenization warmups
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: null,
|
||||
youtubePlaybackFlowPending: false,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
|
||||
@@ -115,7 +115,7 @@ test('initial args handler forwards args to cli handler', () => {
|
||||
|
||||
test('initial args handler bootstraps overlay before initial overlay-runtime commands', () => {
|
||||
const calls: string[] = [];
|
||||
const args = { youtubePlay: 'https://youtube.com/watch?v=abc' } as never;
|
||||
const args = { settings: true } as never;
|
||||
const handleInitialArgs = createHandleInitialArgsHandler({
|
||||
getInitialArgs: () => args,
|
||||
isBackgroundMode: () => false,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { SubtitleData } from '../../types';
|
||||
|
||||
export function createHandleMpvSubtitleChangeHandler(deps: {
|
||||
shouldSuppressSubtitleEvents?: () => boolean;
|
||||
setCurrentSubText: (text: string) => void;
|
||||
getImmediateSubtitlePayload?: (text: string) => SubtitleData | null;
|
||||
emitImmediateSubtitle?: (payload: SubtitleData) => void;
|
||||
@@ -11,10 +10,6 @@ export function createHandleMpvSubtitleChangeHandler(deps: {
|
||||
}) {
|
||||
return ({ text }: { text: string }): void => {
|
||||
deps.setCurrentSubText(text);
|
||||
if (deps.shouldSuppressSubtitleEvents?.()) {
|
||||
deps.refreshDiscordPresence();
|
||||
return;
|
||||
}
|
||||
const immediatePayload = deps.getImmediateSubtitlePayload?.(text) ?? null;
|
||||
if (immediatePayload) {
|
||||
(deps.emitImmediateSubtitle ?? deps.broadcastSubtitle)(immediatePayload);
|
||||
@@ -30,27 +25,19 @@ export function createHandleMpvSubtitleChangeHandler(deps: {
|
||||
}
|
||||
|
||||
export function createHandleMpvSubtitleAssChangeHandler(deps: {
|
||||
shouldSuppressSubtitleEvents?: () => boolean;
|
||||
setCurrentSubAssText: (text: string) => void;
|
||||
broadcastSubtitleAss: (text: string) => void;
|
||||
}) {
|
||||
return ({ text }: { text: string }): void => {
|
||||
deps.setCurrentSubAssText(text);
|
||||
if (deps.shouldSuppressSubtitleEvents?.()) {
|
||||
return;
|
||||
}
|
||||
deps.broadcastSubtitleAss(text);
|
||||
};
|
||||
}
|
||||
|
||||
export function createHandleMpvSecondarySubtitleChangeHandler(deps: {
|
||||
shouldSuppressSubtitleEvents?: () => boolean;
|
||||
broadcastSecondarySubtitle: (text: string) => void;
|
||||
}) {
|
||||
return ({ text }: { text: string }): void => {
|
||||
if (deps.shouldSuppressSubtitleEvents?.()) {
|
||||
return;
|
||||
}
|
||||
deps.broadcastSecondarySubtitle(text);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ test('main mpv event binder wires callbacks through to runtime deps', () => {
|
||||
calls.push('post-watch');
|
||||
},
|
||||
logSubtitleTimingError: () => calls.push('subtitle-error'),
|
||||
shouldSuppressSubtitleEvents: () => false,
|
||||
|
||||
setCurrentSubText: (text) => calls.push(`set-sub:${text}`),
|
||||
broadcastSubtitle: (payload) => calls.push(`broadcast-sub:${payload.text}`),
|
||||
onSubtitleChange: (text) => calls.push(`subtitle-change:${text}`),
|
||||
@@ -94,67 +92,3 @@ test('main mpv event binder wires callbacks through to runtime deps', () => {
|
||||
assert.ok(calls.includes('sync-immersion'));
|
||||
assert.ok(calls.includes('flush-playback'));
|
||||
});
|
||||
|
||||
test('main mpv event binder suppresses subtitle broadcasts while youtube flow is pending', () => {
|
||||
const handlers = new Map<string, (payload: unknown) => void>();
|
||||
const calls: string[] = [];
|
||||
|
||||
const bind = createBindMpvMainEventHandlersHandler({
|
||||
reportJellyfinRemoteStopped: () => {},
|
||||
syncOverlayMpvSubtitleSuppression: () => {},
|
||||
resetSubtitleSidebarEmbeddedLayout: () => {},
|
||||
hasInitialJellyfinPlayArg: () => false,
|
||||
isOverlayRuntimeInitialized: () => false,
|
||||
isQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
isMpvConnected: () => false,
|
||||
quitApp: () => {},
|
||||
recordImmersionSubtitleLine: () => {},
|
||||
hasSubtitleTimingTracker: () => false,
|
||||
recordSubtitleTiming: () => {},
|
||||
maybeRunAnilistPostWatchUpdate: async () => {},
|
||||
logSubtitleTimingError: () => {},
|
||||
shouldSuppressSubtitleEvents: () => true,
|
||||
setCurrentSubText: (text) => calls.push(`set-sub:${text}`),
|
||||
broadcastSubtitle: (payload) => calls.push(`broadcast-sub:${payload.text}`),
|
||||
onSubtitleChange: (text) => calls.push(`subtitle-change:${text}`),
|
||||
refreshDiscordPresence: () => calls.push('presence-refresh'),
|
||||
setCurrentSubAssText: (text) => calls.push(`set-ass:${text}`),
|
||||
broadcastSubtitleAss: (text) => calls.push(`broadcast-ass:${text}`),
|
||||
broadcastSecondarySubtitle: (text) => calls.push(`broadcast-secondary:${text}`),
|
||||
updateCurrentMediaPath: () => {},
|
||||
restoreMpvSubVisibility: () => {},
|
||||
getCurrentAnilistMediaKey: () => null,
|
||||
resetAnilistMediaTracking: () => {},
|
||||
maybeProbeAnilistDuration: () => {},
|
||||
ensureAnilistMediaGuess: () => {},
|
||||
syncImmersionMediaState: () => {},
|
||||
updateCurrentMediaTitle: () => {},
|
||||
resetAnilistMediaGuessState: () => {},
|
||||
notifyImmersionTitleUpdate: () => {},
|
||||
recordPlaybackPosition: () => {},
|
||||
recordMediaDuration: () => {},
|
||||
reportJellyfinRemoteProgress: () => {},
|
||||
recordPauseState: () => {},
|
||||
updateSubtitleRenderMetrics: () => {},
|
||||
setPreviousSecondarySubVisibility: () => {},
|
||||
});
|
||||
|
||||
bind({
|
||||
on: (event, handler) => {
|
||||
handlers.set(event, handler as (payload: unknown) => void);
|
||||
},
|
||||
});
|
||||
|
||||
handlers.get('subtitle-change')?.({ text: 'line' });
|
||||
handlers.get('subtitle-ass-change')?.({ text: 'ass' });
|
||||
handlers.get('secondary-subtitle-change')?.({ text: 'sec' });
|
||||
|
||||
assert.ok(calls.includes('set-sub:line'));
|
||||
assert.ok(calls.includes('set-ass:ass'));
|
||||
assert.ok(calls.includes('presence-refresh'));
|
||||
assert.ok(!calls.includes('broadcast-sub:line'));
|
||||
assert.ok(!calls.includes('subtitle-change:line'));
|
||||
assert.ok(!calls.includes('broadcast-ass:ass'));
|
||||
assert.ok(!calls.includes('broadcast-secondary:sec'));
|
||||
});
|
||||
|
||||
@@ -35,7 +35,6 @@ export function createBindMpvMainEventHandlersHandler(deps: {
|
||||
recordSubtitleTiming: (text: string, start: number, end: number) => void;
|
||||
maybeRunAnilistPostWatchUpdate: () => Promise<void>;
|
||||
logSubtitleTimingError: (message: string, error: unknown) => void;
|
||||
shouldSuppressSubtitleEvents?: () => boolean;
|
||||
|
||||
setCurrentSubText: (text: string) => void;
|
||||
getImmediateSubtitlePayload?: (text: string) => SubtitleData | null;
|
||||
@@ -100,7 +99,6 @@ export function createBindMpvMainEventHandlersHandler(deps: {
|
||||
logError: (message, error) => deps.logSubtitleTimingError(message, error),
|
||||
});
|
||||
const handleMpvSubtitleChange = createHandleMpvSubtitleChangeHandler({
|
||||
shouldSuppressSubtitleEvents: () => deps.shouldSuppressSubtitleEvents?.() ?? false,
|
||||
setCurrentSubText: (text) => deps.setCurrentSubText(text),
|
||||
getImmediateSubtitlePayload: (text) => deps.getImmediateSubtitlePayload?.(text) ?? null,
|
||||
emitImmediateSubtitle: (payload) => deps.emitImmediateSubtitle?.(payload),
|
||||
@@ -109,12 +107,10 @@ export function createBindMpvMainEventHandlersHandler(deps: {
|
||||
refreshDiscordPresence: () => deps.refreshDiscordPresence(),
|
||||
});
|
||||
const handleMpvSubtitleAssChange = createHandleMpvSubtitleAssChangeHandler({
|
||||
shouldSuppressSubtitleEvents: () => deps.shouldSuppressSubtitleEvents?.() ?? false,
|
||||
setCurrentSubAssText: (text) => deps.setCurrentSubAssText(text),
|
||||
broadcastSubtitleAss: (text) => deps.broadcastSubtitleAss(text),
|
||||
});
|
||||
const handleMpvSecondarySubtitleChange = createHandleMpvSecondarySubtitleChangeHandler({
|
||||
shouldSuppressSubtitleEvents: () => deps.shouldSuppressSubtitleEvents?.() ?? false,
|
||||
broadcastSecondarySubtitle: (text) => deps.broadcastSecondarySubtitle(text),
|
||||
});
|
||||
const handleMpvMediaPathChange = createHandleMpvMediaPathChangeHandler({
|
||||
|
||||
@@ -25,7 +25,6 @@ test('mpv main event main deps map app state updates and delegate callbacks', as
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: false,
|
||||
youtubePlaybackFlowPending: false,
|
||||
};
|
||||
|
||||
const deps = createBuildBindMpvMainEventHandlersMainDepsHandler({
|
||||
@@ -75,7 +74,6 @@ test('mpv main event main deps map app state updates and delegate callbacks', as
|
||||
deps.recordSubtitleTiming('y', 0, 1);
|
||||
await deps.maybeRunAnilistPostWatchUpdate();
|
||||
deps.logSubtitleTimingError('err', new Error('boom'));
|
||||
assert.equal(deps.shouldSuppressSubtitleEvents?.(), false);
|
||||
deps.setCurrentSubText('sub');
|
||||
deps.broadcastSubtitle({ text: 'sub', tokens: null });
|
||||
deps.onSubtitleChange('sub');
|
||||
@@ -119,7 +117,7 @@ test('mpv main event main deps map app state updates and delegate callbacks', as
|
||||
assert.ok(calls.includes('reset-sidebar-layout'));
|
||||
});
|
||||
|
||||
test('mpv main event main deps suppress subtitle events while youtube flow is pending', () => {
|
||||
test('mpv main event main deps wire subtitle callbacks without suppression gate', () => {
|
||||
const deps = createBuildBindMpvMainEventHandlersMainDepsHandler({
|
||||
appState: {
|
||||
initialArgs: null,
|
||||
@@ -131,7 +129,6 @@ test('mpv main event main deps suppress subtitle events while youtube flow is pe
|
||||
currentSubAssText: '',
|
||||
playbackPaused: null,
|
||||
previousSecondarySubVisibility: false,
|
||||
youtubePlaybackFlowPending: true,
|
||||
},
|
||||
getQuitOnDisconnectArmed: () => false,
|
||||
scheduleQuitCheck: () => {},
|
||||
@@ -158,5 +155,6 @@ test('mpv main event main deps suppress subtitle events while youtube flow is pe
|
||||
refreshDiscordPresence: () => {},
|
||||
})();
|
||||
|
||||
assert.equal(deps.shouldSuppressSubtitleEvents?.(), true);
|
||||
deps.setCurrentSubText('sub');
|
||||
assert.equal(typeof deps.setCurrentSubText, 'function');
|
||||
});
|
||||
|
||||
@@ -34,7 +34,6 @@ export function createBuildBindMpvMainEventHandlersMainDepsHandler(deps: {
|
||||
currentSubtitleData?: SubtitleData | null;
|
||||
playbackPaused: boolean | null;
|
||||
previousSecondarySubVisibility: boolean | null;
|
||||
youtubePlaybackFlowPending: boolean;
|
||||
};
|
||||
getQuitOnDisconnectArmed: () => boolean;
|
||||
scheduleQuitCheck: (callback: () => void) => void;
|
||||
@@ -120,7 +119,6 @@ export function createBuildBindMpvMainEventHandlersMainDepsHandler(deps: {
|
||||
maybeRunAnilistPostWatchUpdate: () => deps.maybeRunAnilistPostWatchUpdate(),
|
||||
logSubtitleTimingError: (message: string, error: unknown) =>
|
||||
deps.logSubtitleTimingError(message, error),
|
||||
shouldSuppressSubtitleEvents: () => deps.appState.youtubePlaybackFlowPending,
|
||||
setCurrentSubText: (text: string) => {
|
||||
deps.appState.currentSubText = text;
|
||||
},
|
||||
|
||||
@@ -6,7 +6,6 @@ import type { YoutubePickerOpenPayload } from '../../types';
|
||||
const payload: YoutubePickerOpenPayload = {
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com/watch?v=abc',
|
||||
mode: 'download',
|
||||
tracks: [],
|
||||
defaultPrimaryTrackId: null,
|
||||
defaultSecondaryTrackId: null,
|
||||
|
||||
@@ -95,14 +95,14 @@ test('transitionAnilistUpdateInFlightState updates inFlight only', () => {
|
||||
assert.notEqual(transitioned, current);
|
||||
});
|
||||
|
||||
test('applyStartupState does not mark youtube playback flow pending from startup args alone', () => {
|
||||
test('applyStartupState preserves cleared startup-only runtime flags', () => {
|
||||
const appState = createAppState({
|
||||
mpvSocketPath: '/tmp/mpv.sock',
|
||||
texthookerPort: 4000,
|
||||
});
|
||||
|
||||
applyStartupState(appState, {
|
||||
initialArgs: parseArgs(['--youtube-play', 'https://www.youtube.com/watch?v=video123']),
|
||||
initialArgs: parseArgs(['--settings']),
|
||||
mpvSocketPath: '/tmp/mpv.sock',
|
||||
texthookerPort: 4000,
|
||||
backendOverride: null,
|
||||
@@ -111,5 +111,5 @@ test('applyStartupState does not mark youtube playback flow pending from startup
|
||||
backgroundMode: false,
|
||||
});
|
||||
|
||||
assert.equal(appState.youtubePlaybackFlowPending, false);
|
||||
assert.equal(appState.initialArgs?.settings, true);
|
||||
});
|
||||
|
||||
@@ -188,7 +188,6 @@ export interface AppState {
|
||||
overlayDebugVisualizationEnabled: boolean;
|
||||
statsOverlayVisible: boolean;
|
||||
subsyncInProgress: boolean;
|
||||
youtubePlaybackFlowPending: boolean;
|
||||
initialArgs: CliArgs | null;
|
||||
mpvSocketPath: string;
|
||||
texthookerPort: number;
|
||||
@@ -273,7 +272,6 @@ export function createAppState(values: AppStateInitialValues): AppState {
|
||||
fieldGroupingResolver: null,
|
||||
fieldGroupingResolverSequence: 0,
|
||||
subsyncInProgress: false,
|
||||
youtubePlaybackFlowPending: false,
|
||||
initialArgs: null,
|
||||
mpvSocketPath: values.mpvSocketPath,
|
||||
texthookerPort: values.texthookerPort,
|
||||
@@ -293,7 +291,6 @@ export function createAppState(values: AppStateInitialValues): AppState {
|
||||
|
||||
export function applyStartupState(appState: AppState, startupState: StartupState): void {
|
||||
appState.initialArgs = startupState.initialArgs;
|
||||
appState.youtubePlaybackFlowPending = false;
|
||||
appState.mpvSocketPath = startupState.mpvSocketPath;
|
||||
appState.texthookerPort = startupState.texthookerPort;
|
||||
appState.backendOverride = startupState.backendOverride;
|
||||
|
||||
@@ -151,7 +151,6 @@ test('youtube track picker close restores focus and mouse-ignore state', () => {
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com',
|
||||
mode: 'download',
|
||||
tracks: [],
|
||||
defaultPrimaryTrackId: null,
|
||||
defaultSecondaryTrackId: null,
|
||||
@@ -241,7 +240,6 @@ test('youtube track picker re-acknowledges repeated open requests', () => {
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com/one',
|
||||
mode: 'download',
|
||||
tracks: [],
|
||||
defaultPrimaryTrackId: null,
|
||||
defaultSecondaryTrackId: null,
|
||||
@@ -250,7 +248,6 @@ test('youtube track picker re-acknowledges repeated open requests', () => {
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-2',
|
||||
url: 'https://example.com/two',
|
||||
mode: 'generate',
|
||||
tracks: [],
|
||||
defaultPrimaryTrackId: null,
|
||||
defaultSecondaryTrackId: null,
|
||||
@@ -327,7 +324,6 @@ test('youtube track picker surfaces rejected resolve calls as modal status', asy
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com',
|
||||
mode: 'download',
|
||||
tracks: [
|
||||
{
|
||||
id: 'auto:ja-orig',
|
||||
@@ -432,7 +428,6 @@ test('youtube track picker ignores duplicate resolve submissions while request i
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com',
|
||||
mode: 'download',
|
||||
tracks: [
|
||||
{
|
||||
id: 'auto:ja-orig',
|
||||
@@ -534,7 +529,6 @@ test('youtube track picker only consumes handled keys', async () => {
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com',
|
||||
mode: 'download',
|
||||
tracks: [],
|
||||
defaultPrimaryTrackId: null,
|
||||
defaultSecondaryTrackId: null,
|
||||
@@ -640,7 +634,6 @@ test('youtube track picker ignores immediate Enter after open before allowing ke
|
||||
modal.openYoutubePickerModal({
|
||||
sessionId: 'yt-1',
|
||||
url: 'https://example.com',
|
||||
mode: 'download',
|
||||
tracks: [
|
||||
{
|
||||
id: 'auto:ja-orig',
|
||||
|
||||
@@ -96,7 +96,7 @@ export function createYoutubeTrackPickerModal(
|
||||
|
||||
function applyPayload(payload: YoutubePickerOpenPayload): void {
|
||||
ctx.state.youtubePickerPayload = payload;
|
||||
ctx.dom.youtubePickerTitle.textContent = `${payload.mode === 'generate' ? 'Generate' : 'Download'} subtitles for ${payload.url}`;
|
||||
ctx.dom.youtubePickerTitle.textContent = `Select YouTube subtitles for ${payload.url}`;
|
||||
ctx.dom.youtubePickerPrimarySelect.innerHTML = '';
|
||||
ctx.dom.youtubePickerSecondarySelect.innerHTML = '';
|
||||
|
||||
|
||||
@@ -561,7 +561,6 @@ export interface ControllerRuntimeSnapshot {
|
||||
}
|
||||
|
||||
export type JimakuLanguagePreference = 'ja' | 'en' | 'none';
|
||||
export type YoutubeFlowMode = 'download' | 'generate';
|
||||
export type { YoutubeTrackKind };
|
||||
|
||||
export interface YoutubeTrackOption {
|
||||
@@ -578,7 +577,6 @@ export interface YoutubeTrackOption {
|
||||
export interface YoutubePickerOpenPayload {
|
||||
sessionId: string;
|
||||
url: string;
|
||||
mode: YoutubeFlowMode;
|
||||
tracks: YoutubeTrackOption[];
|
||||
defaultPrimaryTrackId: string | null;
|
||||
defaultSecondaryTrackId: string | null;
|
||||
|
||||
Reference in New Issue
Block a user