Last active
January 25, 2022 09:16
-
-
Save bxb100/6734e7fdc5396bcfcaf34c809c8334f6 to your computer and use it in GitHub Desktop.
Dropover action script
This file contains 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 | |
timestamp() { | |
date +%s | |
} | |
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' | |
for var in "$@" | |
do | |
timestamp=$(timestamp) | |
files="encoded_image=@$var" | |
tt=$( curl --location --request POST "https://lens.google.com/upload?ep=ccm&s=&st=$timestamp" \ | |
--form "$files" | grep -oE 'https?:\/\/.*\"' | tr -d '"' ) | |
echo "$tt" | |
if [[ $tt =~ $regex ]]; then | |
echo "URL found" | |
open "$tt" | |
break | |
else | |
echo "URL not found, tt: $tt" 1>&2 | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/3183444/check-for-valid-link-url