Skip to content

Instantly share code, notes, and snippets.

@bxb100
Last active January 25, 2022 09:16
Show Gist options
  • Save bxb100/6734e7fdc5396bcfcaf34c809c8334f6 to your computer and use it in GitHub Desktop.
Save bxb100/6734e7fdc5396bcfcaf34c809c8334f6 to your computer and use it in GitHub Desktop.
Dropover action script
#!/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