From 780ac718550ce99e3da0aded7f1bb4732bf8930a Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 8 Sep 2024 00:33:13 -0700 Subject: [PATCH] check if article exists in archive already - open url in browser to archive if not exists yet --- archiveit.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/archiveit.sh b/archiveit.sh index 201968d..7dfdd0f 100755 --- a/archiveit.sh +++ b/archiveit.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash +set -Eeuo pipefail + BASE_URL=https://archive.is/timegate +ARCHIVE_URL=https://archive.is/?url BROWSER=firefox check() { @@ -9,6 +12,11 @@ check() { echo "Please provide an article to archive" >&2 exit 1 fi + if https --verify no "$BASE_URL/$article" | grep -iq "archive this url"; then + echo "Article not found in archive... archiving now" >&2 + $BROWSER "$ARCHIVE_URL=$article" + exit 0 + fi } while getopts "o:p:" opt; do