mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 12:11:28 -07:00
feat(subsync): add replace option and deterministic retimed naming
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { codecToExtension } from './utils';
|
||||
import { codecToExtension, getSubsyncConfig } from './utils';
|
||||
|
||||
test('codecToExtension maps stream/web formats to ffmpeg extractable extensions', () => {
|
||||
assert.equal(codecToExtension('subrip'), 'srt');
|
||||
@@ -12,3 +12,13 @@ test('codecToExtension maps stream/web formats to ffmpeg extractable extensions'
|
||||
test('codecToExtension returns null for unsupported codecs', () => {
|
||||
assert.equal(codecToExtension('unsupported-codec'), null);
|
||||
});
|
||||
|
||||
test('getSubsyncConfig defaults replace to true', () => {
|
||||
assert.equal(getSubsyncConfig(undefined).replace, true);
|
||||
assert.equal(getSubsyncConfig({}).replace, true);
|
||||
});
|
||||
|
||||
test('getSubsyncConfig respects explicit replace value', () => {
|
||||
assert.equal(getSubsyncConfig({ replace: false }).replace, false);
|
||||
assert.equal(getSubsyncConfig({ replace: true }).replace, true);
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface SubsyncResolvedConfig {
|
||||
alassPath: string;
|
||||
ffsubsyncPath: string;
|
||||
ffmpegPath: string;
|
||||
replace?: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_SUBSYNC_EXECUTABLE_PATHS = {
|
||||
@@ -55,6 +56,7 @@ export function getSubsyncConfig(config: SubsyncConfig | undefined): SubsyncReso
|
||||
alassPath: resolvePath(config?.alass_path, DEFAULT_SUBSYNC_EXECUTABLE_PATHS.alass),
|
||||
ffsubsyncPath: resolvePath(config?.ffsubsync_path, DEFAULT_SUBSYNC_EXECUTABLE_PATHS.ffsubsync),
|
||||
ffmpegPath: resolvePath(config?.ffmpeg_path, DEFAULT_SUBSYNC_EXECUTABLE_PATHS.ffmpeg),
|
||||
replace: config?.replace ?? DEFAULT_CONFIG.subsync.replace,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user