#!/usr/bin/env tsx // Check which of a social channel's archived posts have been deleted at the // source. // // pnpm --filter yt-dlp-transcript-common exec tsx \ // bin/check-post-availability.ts --slug [--mode stale|unchecked|all] [--limit N] import { getPaths } from "../lib/paths"; import { CHECK_POST_AVAILABILITY_MODES, checkPostAvailability, type CheckPostAvailabilityMode, } from "../controller/checkPostAvailability"; import { parseFlags } from "./_parseFlags"; const flags = parseFlags(process.argv.slice(2)); const slug = flags.slug; if (!slug) { console.error( "Usage: check-post-availability.ts --slug [--mode stale|unchecked|all] [--limit N]", ); process.exit(2); } const mode = (flags.mode ?? "stale") as CheckPostAvailabilityMode; if (!CHECK_POST_AVAILABILITY_MODES.includes(mode)) { console.error(`--mode must be one of: ${CHECK_POST_AVAILABILITY_MODES.join(", ")}`); process.exit(2); } const limitRaw = flags.limit ? Number(flags.limit) : undefined; checkPostAvailability({ paths: getPaths(), slug, mode, limit: typeof limitRaw === "number" && Number.isFinite(limitRaw) && limitRaw > 0 ? Math.floor(limitRaw) : undefined, onLog: (line) => console.log(line), }) .then((r) => { if (!r.ok) { console.error(`Failed: ${r.error}`); process.exit(1); } console.log( `Checked ${r.checked}; ${r.newlyDeleted.length} newly deleted; ` + `${r.deleted} deleted overall; ${r.remaining} never checked.`, ); }) .catch((err) => { console.error(err); process.exit(1); });