From b95b768e44288f74c70ccfc9886d4b4976b98a16 Mon Sep 17 00:00:00 2001 From: halo Date: Sun, 19 Apr 2026 19:51:55 -0400 Subject: [PATCH] add input delay option --- README.md | 4 ++++ src/input.ts | 4 ++++ src/runner.ts | 3 +++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index d83cc20a..edf9e217 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ Defaults to `false`. Only capture the URL if the most recent existing capture is older than this value. Accepts SPN2 timedelta strings (e.g. `1d`, `3h 20m`) or plain seconds (e.g. `3600`). Supports a comma-separated pair (e.g. `1d,7d`) to apply a different value to outlinks. +### `delayBetweenRequests` + +Time, in milliseconds, to wait between web requests. Use this to work with rate-limited hosting. + ## Outputs ### `wayback_url` diff --git a/src/input.ts b/src/input.ts index 3f350645..15942024 100644 --- a/src/input.ts +++ b/src/input.ts @@ -18,6 +18,7 @@ export default class Input { readonly ifNotArchivedWithin = this.getInput('ifNotArchivedWithin', { trimWhitespace: true, }); + readonly delayBetweenRequests; constructor() { const urls = this.getMultilineInput('url', { @@ -25,6 +26,9 @@ export default class Input { trimWhitespace: true, }); + const delayInput = this.getInput('delayBetweenRequests', { trimWhitespace: true }); + this.delayBetweenRequests = delayInput ? Number(delayInput) : null; + this.url = urls.length > 0 ? urls : this.detectFromCname(); this.validate(); } diff --git a/src/runner.ts b/src/runner.ts index 18d04722..ebb6ef9d 100644 --- a/src/runner.ts +++ b/src/runner.ts @@ -26,6 +26,9 @@ export default async function run(): Promise { log.error(`Archive process failed for ${url}: ${err.message}`); failures.push({ url, error: err }); } + if (input.delayBetweenRequests) { + await Promise.delay(input.delayBetweenRequests); + } } writeOutputs(results);