// `archilyzer archive-org refresh [--dry-run]` — every archive.org file // record of a channel brought up to its provenance's rules // (controller/archiveOrgRefresh.ts): the title a file's name carries (where the // item gives the file none) and the day it starts with, for a mirror with no // uploaded info.json. Offline: nothing is fetched. Prints old → new per key; a // second run changes nothing. import { isValidChannelSlug } from "../controller/channels"; import { refreshArchiveOrgRecords } from "../controller/archiveOrgRefresh"; import { getPaths, type Paths } from "../lib/paths"; export async function main(opts: { slug: string; dryRun: boolean; paths?: Paths }): Promise { if (!isValidChannelSlug(opts.slug)) { console.error(`archive-org refresh: "${opts.slug}" is not a channel slug`); return 2; } try { const r = await refreshArchiveOrgRecords({ slug: opts.slug, paths: opts.paths ?? getPaths(), dryRun: opts.dryRun, onLog: (line) => console.log(line.replace(/\n$/, "")), }); const would = opts.dryRun ? "would be " : ""; console.log( `${opts.dryRun ? "dry run: " : ""}${r.fileRecords} archive.org file records, ` + `${r.changed.length} ${would}refreshed, ` + `${r.sidecars} provenance sidecars ${would}updated` + (r.failed.length > 0 ? `, ${r.failed.length} failed` : "") + ".", ); return r.failed.length > 0 ? 1 : 0; } catch (err) { console.error(`archive-org refresh: ${(err as Error).message}`); return 1; } }