"use client"; // A Wayback pages channel's records (release 37 S4): each with what its // capture is (PageCaptureFacts — the kind, "Original (may be gone)", "Wayback // Machine copy, ", the version list, no content, the fallback note), its // shot when one is captured, and Capture: the screenshot of the record as the // archive replays it, and its images (`capture-posts`, on archive.org's pace). import { useState } from "react"; import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog"; import { PageCaptureFacts } from "yt-dlp-transcript-common/components/PageCaptureFacts"; import type { PageCaptureView } from "yt-dlp-transcript-common/lib/waybackPages/view"; import { cancelJobAction } from "../../../jobs/actions"; import { capturePostsAction } from "../socialActions"; export type WaybackPageRecordRow = { id: string; title: string; view: PageCaptureView; // The captured shot, when there is one (the editor's posts-media route). shot?: string; // How many images the capture saved. images?: number; }; export function WaybackPageRecords({ slug, rows }: { slug: string; rows: WaybackPageRecordRow[] }) { const [picked, setPicked] = useState([]); const [force, setForce] = useState(false); const toggle = (id: string) => setPicked((p) => (p.includes(id) ? p.filter((x) => x !== id) : [...p, id])); const ids = picked.length > 0 ? picked : rows.filter((r) => !r.shot).map((r) => r.id); return (
{rows.map((r) => ( ))}
Pick Page Kind Captured
toggle(r.id)} /> {r.title} {r.view.noContent && (no content)}
{r.view.versions ? `${r.view.versions.count} captures` : "The capture"} {r.shot ? " · shot" : ""}
{r.shot && ( // eslint-disable-next-line @next/next/no-img-element -- a capture of unknown size, served from the corpus {`Screenshot )} {r.images ? {r.images} image(s) saved : null}
{r.view.kind} {r.view.captureDate} {r.view.source && {r.view.links.copy.label.replace(/ copy, .*$/, "")}}
capturePostsAction(slug, force && picked.length === 0 ? rows.map((r) => r.id) : ids, undefined, true, true, force)} cancelAction={cancelJobAction} buttonLabel={ picked.length > 0 ? `Capture ${picked.length} picked` : `Capture ${ids.length} without a shot` } runningLabel="Capturing…" label={`Capture page records of ${slug}`} disabled={ids.length === 0 && !(force && rows.length > 0)} />
); }