Add video poster frames and rework the media status row

This commit is contained in:
Fisto
2026-09-16 12:40:10 +02:00
parent f9b4041157
commit 043d1cd3c5
9 changed files with 124 additions and 12 deletions
+29 -1
View File
@@ -4,11 +4,12 @@
*/
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { createHash } from "node:crypto";
import { existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { downloadOne, downloadPreview, previewUrlFor } from "../src/download.js";
import { downloadOne, downloadPreview, previewUrlFor, videoPoster } from "../src/download.js";
import { ScrapeEngine, type FetchPage, type ScrapeBackend } from "../src/engine.js";
import { extractMedia } from "../src/extract.js";
import { PuppetBackend } from "../src/puppet-backend.js";
@@ -711,6 +712,33 @@ void (async () => {
store.close();
});
await test("videoPoster extracts a cached frame", async () => {
const dir = join(root, "poster-test");
mkdirSync(dir, { recursive: true });
const videoPath = join(dir, "clip.mp4");
try {
execFileSync("ffmpeg", [
"-v",
"error",
"-y",
"-f",
"lavfi",
"-i",
"testsrc=duration=1:size=64x64:rate=5",
videoPath
]);
} catch {
console.log("ok - videoPoster skipped (no ffmpeg)");
return;
}
const poster = await videoPoster(videoPath, dir);
assert.ok(poster?.hash);
assert.ok((poster?.bytes ?? 0) > 0);
assert.equal(existsSync(join(dir, `${poster?.hash}.webp`)), true);
});
await test("snowflake helpers round-trip dates", () => {
const id = snowflakeFromIso("2026-09-16T00:00:00.000Z");
assert.ok(id);