// `archilyzer feeds backfill-metadata [--feed ] [--dry-run]` — // a podcast channel's records completed from its RSS feed, offline. The work // and its rules are controller/feedMetadataBackfill.ts; the editor runs the // same function as the `feed-metadata` job (`POST /api/ops/feed-metadata`). // // One fetch of the feed and nothing else on the network. It writes // metadata.info.json files through the history, atomically; it does not see // the editor's queues, so not beside a download on the same channel. import { isValidChannelSlug } from "../controller/channels"; import { backfillFeedMetadata, feedBackfillSummary, } from "../controller/feedMetadataBackfill"; export async function main(opts: { slug: string; feedUrl?: string; dryRun: boolean; signal?: AbortSignal; }): Promise { if (!isValidChannelSlug(opts.slug)) { console.error(`feeds backfill-metadata: "${opts.slug}" is not a channel slug`); return 2; } try { const result = await backfillFeedMetadata({ slug: opts.slug, ...(opts.feedUrl ? { feedUrl: opts.feedUrl } : {}), dryRun: opts.dryRun, requestedBy: "cli", onLog: (line) => console.log(line.replace(/\n$/, "")), ...(opts.signal ? { signal: opts.signal } : {}), }); console.log(feedBackfillSummary(result)); return result.failed.length > 0 || opts.signal?.aborted ? 1 : 0; } catch (err) { console.error(`feeds backfill-metadata: ${(err as Error).message}`); return 1; } }