-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshotUp.sh
executable file
·35 lines (24 loc) · 1.29 KB
/
shotUp.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
35
#!/bin/bash
## yet another screenshots grabber and uploader - shotUp
# idea from: http://blog.flienteen.com/2010/08/iuf-linux-image-uploader-v15.html
username='[email protected]' # your username goes there
password='supermegasecretpassword' # your password goes there
curlOpt=' -s -b cookies.txt -c cookies.txt -A "Mozilla/5.0 " '
main_page=$(curl $curlOpt http://imgur.com/)
status=$(echo $main_page | sed -n 's/.*id="logged-in">[ ]*<strong class="green">\([^"]*\)<\/strong>.*/\1/p')
if [ -z "$status" ]; then
curl $curlOpt -d "username=$username&password=$password&remember=remember&submit=Continue" 'http://imgur.com/signin' > /dev/null
main_page=$(curl $curlOpt http://imgur.com/)
status=$(echo $main_page | sed -n 's/.*id="logged-in">[ ]*<strong class="green">\([^"]*\)<\/strong>.*/\1/p')
fi
if [ -z "$status" ]
then
echo "Autentificare esuata..."
exit 1
fi
filename="/tmp/shot_$(date +%d-%m-%y\_%H:%M:%S).png"
scrot -s $filename
response=$(curl -b cookies.txt -c cookies.txt -s -F "image=@$filename" -F "key=486690f872c678126a2c09a9e196ce1b" http://imgur.com/api/upload.xml)
direct_link=$(echo $response | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*")
echo $direct_link
echo -n $direct_link | xsel --clipboard --input