feat(subtitles): add local Japanese subtitle generation (#240)

This commit is contained in:
2026-09-15 21:43:11 -07:00
committed by GitHub
parent 6841a37a22
commit 2831e05124
90 changed files with 4934 additions and 57 deletions
@@ -0,0 +1,32 @@
import { constants } from 'node:fs';
import { copyFile, link } from 'node:fs/promises';
import { homedir } from 'node:os';
import path from 'node:path';
export function expandSubtitleGenerationPath(value: string): string {
if (value === '~') return homedir();
if (value.startsWith('~/') || value.startsWith('~\\'))
return path.join(homedir(), value.slice(2));
return value;
}
// Prefer atomic publication. Filesystems without hard links still get exclusive creation.
export async function publishSubtitleGenerationFile(
source: string,
destination: string,
): Promise<void> {
try {
await link(source, destination);
} catch (error) {
if (
!(error instanceof Error) ||
!('code' in error) ||
(error.code !== 'ENOTSUP' &&
error.code !== 'EOPNOTSUPP' &&
error.code !== 'EPERM' &&
error.code !== 'EXDEV')
)
throw error;
await copyFile(source, destination, constants.COPYFILE_EXCL);
}
}