Skip to content

Instantly share code, notes, and snippets.

@rkmax
Created January 25, 2024 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkmax/6f5ff140d54352531d4fd9fcf8dcc641 to your computer and use it in GitHub Desktop.
Save rkmax/6f5ff140d54352531d4fd9fcf8dcc641 to your computer and use it in GitHub Desktop.
Helper script to save a URL to Omnivore.app
#!/usr/bin/env bash
#
# Helper script to save a URL to Omnivore
#
set -e
if [ -f $HOME/.omnivore ]; then
source $HOME/.omnivore
fi
if [ -z "$OMNIVORE_API_KEY" ]; then
echo "OMNIVORE_API_KEY is not set. Please set it in your environment or in $HOME/.omnivore"
exit 1
fi
save_url() {
urlToSave=$1
clientRequestId=$(uuidgen)
curl \
-X POST \
-H 'content-type: application/json' \
-H "authorization: $OMNIVORE_API_KEY" https://api-prod.omnivore.app/api/graphql \
-d '{ "query": "mutation SaveUrl($input: SaveUrlInput!) { saveUrl(input: $input) { ... on SaveSuccess { url clientRequestId } ... on SaveError { errorCodes message } } }", "variables": { "input": { "clientRequestId": "'"$clientRequestId"'", "source": "api", "url": "'"$urlToSave"'" }} }'
}
if [ $# -eq 1 ]; then
save_url $1
else
echo "Usage: omnivore.sh <url>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment