Created
January 25, 2024 18:41
-
-
Save rkmax/6f5ff140d54352531d4fd9fcf8dcc641 to your computer and use it in GitHub Desktop.
Helper script to save a URL to Omnivore.app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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