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
+19 -5
View File
@@ -362,11 +362,25 @@ export class ScrapeStore {
this.db.prepare("UPDATE media SET preview_error = ? WHERE id = ?").run(error.slice(0, 200), id);
}
/** Fill in dimensions after a download probe. */
updateDimensions(id: number, width: number, height: number): void {
this.db
.prepare("UPDATE media SET width = ?, height = ?, aspect_ratio = ? WHERE id = ?")
.run(width, height, aspectRatioOf(width, height), id);
/** Fill in dimensions and duration after a download probe. */
updateMediaInfo(
id: number,
info: { width?: number | null; height?: number | null; durationSecs?: number | null }
): void {
const sets: string[] = [];
const values: Array<number | null> = [];
if (info.width != null && info.height != null) {
sets.push("width = ?", "height = ?", "aspect_ratio = ?");
values.push(info.width, info.height, aspectRatioOf(info.width, info.height));
}
if (info.durationSecs != null) {
sets.push("duration_secs = ?");
values.push(info.durationSecs);
}
if (!sets.length) return;
this.db.prepare(`UPDATE media SET ${sets.join(", ")} WHERE id = ?`).run(...values, id);
}
/** Distinct posters with their item counts, biggest first. */