drop the built-in Extract Audio entry, and its cache
Extract Audio now exists as a task, with recursion, multi-select scoping, a format choice and multi-track handling — none of which the one-shot menu entry had, since it always produced a single mp3. /extract-audio stays because the file viewer's button plays its output rather than saving it beside the video, but it no longer returns a cached file: like transcription and OCR, it always redoes the work. The path is now named outRel, since it is an output location rather than a cache. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
9d01000578
commit
0c7c015fc3
@@ -849,14 +849,14 @@ router.post('/extract-audio', async (ctx) => {
|
||||
const s = await stat(absPath);
|
||||
if (s.isDirectory()) throw errors.BAD_REQUEST('Cannot extract audio from a directory');
|
||||
|
||||
// No caching: the extraction is always redone and overwrites the previous result. The output still
|
||||
// lives under the user's data dir because this endpoint backs the file viewer's Extract Audio
|
||||
// button, which plays it rather than saving it beside the video — the Extract Audio task is what
|
||||
// writes into the user's folders.
|
||||
const userDataDir = getUserDataDir(user.email);
|
||||
const { dir, name } = parsePath(filePath.replace(/^\/+/, ''));
|
||||
const cacheRel = dir ? `cache/audio/${dir}/${name}.mp3` : `cache/audio/${name}.mp3`;
|
||||
const cacheAbs = resolve(userDataDir, cacheRel);
|
||||
|
||||
if (existsSync(cacheAbs)) {
|
||||
return ctx.json({ audioPath: cacheRel, audioRoot: 'user-data', cached: true });
|
||||
}
|
||||
const outRel = dir ? `cache/audio/${dir}/${name}.mp3` : `cache/audio/${name}.mp3`;
|
||||
const cacheAbs = resolve(userDataDir, outRel);
|
||||
|
||||
await mkdir(dirname(cacheAbs), { recursive: true });
|
||||
|
||||
@@ -871,7 +871,7 @@ router.post('/extract-audio', async (ctx) => {
|
||||
throw errors.BAD_REQUEST(stderr.trim() || 'Audio extraction failed');
|
||||
}
|
||||
|
||||
return ctx.json({ audioPath: cacheRel, audioRoot: 'user-data', cached: false });
|
||||
return ctx.json({ audioPath: outRel, audioRoot: 'user-data', cached: false });
|
||||
});
|
||||
|
||||
// Extract archive (zip, tar, 7z, rar) into a sibling folder
|
||||
|
||||
Reference in New Issue
Block a user