Skip to content

Instantly share code, notes, and snippets.

@bxb100
Last active November 6, 2022 09:39
Show Gist options
  • Save bxb100/4cdfa1b52999ac491b21fd9e1803f58a to your computer and use it in GitHub Desktop.
Save bxb100/4cdfa1b52999ac491b21fd9e1803f58a to your computer and use it in GitHub Desktop.
DropOver 脚本
#!/usr/bin/env bash
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
for var in "$@"
do
files="encoded_image=@$var"
# if this is a gif, get the first frame
if [[ $var =~ \.(gif|mp4)$ ]]; then
tempfile="$TMPDIR$(uuidgen).jpg";
./opt/homebrew/bin/ffmpeg -i "$var" -vf "select=eq(n\,0)" -q:v 3 "$tempfile";
files="encoded_image=@$tempfile";
fi
echo "$files"
tt=$( curl -X POST "https://www.google.com/searchbyimage/upload" \
--form "$files" | grep -oE 'https?:\/\/.*\"' | tr -d '"' )
if [[ $tt =~ $regex ]]; then
open "$tt"
break
else
echo "URL not found, tt: $tt" 1>&2
exit 1
fi
done
@bxb100
Copy link
Author

bxb100 commented Feb 1, 2022

attention: using homebrew install the ffmpeg, so the execute full path is ./opt/homebrew/bin/ffmpeg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment