Files
SubMiner/src/subsync/utils.test.ts
T
sudacode 14330af303 fix(subsync): decode file:// tracks mpv reports for dropped subtitles
- Sync a subtitle dropped onto mpv without hitting "Protocol file: not supported"; decode file:// external-filename/path back to a real path for target, reference, and video
- Stream strip proxy: destroy the connection instead of retrying/502 once a response is handed off, and cap buffered playlist bodies
- Bridge installer: cap downloaded bundle size to guard against a lying/missing content-length
- Anime browser playback: bump generation on dispose so a stale in-flight playEpisode cleans up its own subtitle cache
- Fix a flaky sidecar-process test by binding to an OS-assigned port instead of pre-allocating one
2026-08-14 22:42:22 -07:00

43 lines
1.7 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { codecToExtension, getSubsyncConfig, resolveLocalMediaPath } from './utils';
test('codecToExtension maps stream/web formats to ffmpeg extractable extensions', () => {
assert.equal(codecToExtension('subrip'), 'srt');
assert.equal(codecToExtension('webvtt'), 'vtt');
assert.equal(codecToExtension('vtt'), 'vtt');
assert.equal(codecToExtension('ttml'), 'ttml');
});
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);
});
test('resolveLocalMediaPath decodes file URLs mpv reports for dropped files', () => {
assert.equal(
resolveLocalMediaPath('file:///home/user/subs/%E3%83%AF%E3%83%B3%20sdh.srt'),
'/home/user/subs/ワン sdh.srt',
);
assert.equal(resolveLocalMediaPath('FILE:///tmp/ref.srt'), '/tmp/ref.srt');
});
test('resolveLocalMediaPath leaves plain paths and stream URLs alone', () => {
assert.equal(resolveLocalMediaPath('/tmp/ref.srt'), '/tmp/ref.srt');
assert.equal(
resolveLocalMediaPath('https://jellyfin.example/subs/eng.srt'),
'https://jellyfin.example/subs/eng.srt',
);
// A UNC host has no local path; the caller's own error is the useful one.
assert.equal(resolveLocalMediaPath('file://host/share/ref.srt'), 'file://host/share/ref.srt');
});