7cb2714793
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
534 B
TypeScript
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();
|
|
}
|