import { getPdsUrl } from "./identity.ts"; import type { VideoRecord } from "./lexicons.ts"; export async function getVideoRecord(did: string, rkey: string): Promise { const pdsUrl = await getPdsUrl(did); if (!pdsUrl) throw new Error("Could not resolve PDS"); const url = new URL("/xrpc/com.atproto.repo.getRecord", pdsUrl); url.searchParams.set("repo", did); url.searchParams.set("collection", "blue.cerulea.video.video"); url.searchParams.set("rkey", rkey); const res = await fetch(url, { headers: { "user-agent": "video.cerulea.app" } }); if (!res.ok) throw new Error(`Failed to fetch record: ${res.status}`); const record = await res.json(); return record.value as VideoRecord; }