Files
netfelix-audio-fix/server/services/discover.ts
T

20 lines
534 B
TypeScript

import { existsSync } from "node:fs";
/**
* Recursively discover all video files under the given root directories.
* Returns absolute paths sorted alphabetically.
*/
export async function discoverVideoFiles(roots: string[]): Promise<string[]> {
const glob = new Bun.Glob("**/*.{mkv,mp4,avi,m4v,ts,wmv}");
const results: string[] = [];
for (const root of roots) {
if (!existsSync(root)) continue;
for await (const file of glob.scan({ cwd: root, absolute: true })) {
results.push(file);
}
}
return results.sort();
}