Deduplicate media across scrapes and polish the viewer controls

This commit is contained in:
Fisto
2026-09-16 13:05:31 +02:00
parent 1b5fcfed2f
commit d3f9d20190
12 changed files with 198 additions and 85 deletions
+7 -5
View File
@@ -59,8 +59,10 @@ export interface ScrapeEngineOptions {
download?: DownloadOptions;
/** Cache Discord-hosted image previews after every walk. Default true. */
previews?: boolean;
/** Read dimensions from a downloaded file. Defaults to ffprobe. */
probe?: (path: string) => Promise<{ width: number; height: number } | null>;
/** Read dimensions and duration from a downloaded file. Defaults to ffprobe. */
probe?: (
path: string
) => Promise<{ width: number | null; height: number | null; durationSecs: number | null } | null>;
/** Called when a scrape fails. */
onError?: (scrapeId: string, message: string) => void;
}
@@ -320,11 +322,11 @@ export class ScrapeEngine {
});
meta.downloaded = (meta.downloaded ?? 0) + 1;
if (row.width === null || row.height === null) {
const dimensions = await (this.options.probe ?? probeDimensions)(
if (row.width === null || row.height === null || row.duration_secs === null) {
const info = await (this.options.probe ?? probeDimensions)(
join(targetDir, outcome.path)
);
if (dimensions) store.updateDimensions(row.id, dimensions.width, dimensions.height);
if (info) store.updateMediaInfo(row.id, info);
}
if (row.kind === "video" && !row.preview_hash) {