Deduplicate media across scrapes and polish the viewer controls
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user