Collect discovered video metadata and recommend videos from listening history

This commit is contained in:
Jonathan Sykes
2026-10-03 07:16:51 +08:00
parent 343eb53d89
commit 5154ef5f75
16 changed files with 963 additions and 24 deletions

View File

@@ -134,6 +134,29 @@ export async function initDb() {
);
CREATE INDEX IF NOT EXISTS idx_video_meta_upd ON video_meta (updated_at);
CREATE TABLE IF NOT EXISTS video_meta_sources (
video_id TEXT NOT NULL, source TEXT NOT NULL, discoveries INTEGER NOT NULL DEFAULT 1,
last_seen INTEGER NOT NULL, PRIMARY KEY (video_id, source)
);
CREATE TABLE IF NOT EXISTS video_thumbnails (
video_id TEXT PRIMARY KEY, url TEXT NOT NULL, data BLOB, mime TEXT,
size INTEGER NOT NULL DEFAULT 0, fetched_at INTEGER NOT NULL DEFAULT 0,
retry_at INTEGER NOT NULL DEFAULT 0, attempts INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX IF NOT EXISTS idx_thumb_pending ON video_thumbnails (retry_at) WHERE data IS NULL;
CREATE TABLE IF NOT EXISTS listening_daily (
fingerprint TEXT NOT NULL, day TEXT NOT NULL, video_id TEXT NOT NULL,
plays INTEGER NOT NULL, PRIMARY KEY (fingerprint, day, video_id)
);
CREATE INDEX IF NOT EXISTS idx_listening_video ON listening_daily (video_id, day);
CREATE TABLE IF NOT EXISTS catalog_backfill (
source TEXT PRIMARY KEY, cursor INTEGER NOT NULL DEFAULT 0, ceiling INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS video_channels (
video_id TEXT PRIMARY KEY, channel TEXT NOT NULL, updated_at INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX IF NOT EXISTS idx_video_channel ON video_channels (channel,updated_at DESC,video_id);
-- Shared per-video documents (kind = lyrics | chapters), visible to every
-- user. The live copy is here; every save also lands in video_note_revs
-- as a full snapshot, which is the server-side backup and undo history.