forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeekalink.template.sh
executable file
·34 lines (25 loc) · 966 Bytes
/
peekalink.template.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
############################################
## Set API key. ##
## https://www.peekalink.io/auth/register ##
############################################
api_key=
# @raycast.title Peek a link
# @raycast.author Caleb Stauffer
# @raycast.authorURL https://github.com/crstauf
# @raycast.description Use [Peekalink.io](https://peekalink.io) API to peek specified URL.
# @raycast.icon images/peekalink-logo.png
# @raycast.mode fullOutput
# @raycast.packageName Internet
# @raycast.schemaVersion 1
# @raycast.argument1 { "type": "text", "placeholder": "URL" }
if [ -z ${api_key+x} ]; then
echo "API key is missing.";
exit 1;
fi
regex='(https?)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
if [[ $1 =~ $regex ]]; then
curl -s 'https://api.peekalink.io' -H "X-API-Key: ${api_key}" -H "Content-Type: application/json" -d '{ "link": "'"${1}"'" }' | python -m json.tool
exit 0;
fi
echo "Input is not a valid URL."