scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit b06b7e93bce62c7e87b076b7e3bc5ea2b8062a06
parent b885083b01a578fd135c457b930fbcd8bda819b9
Author: lostd <lostd@2f30.org>
Date:   Thu, 22 Aug 2013 14:02:12 +0300

new apikey, parse output, save links to log, sanity checks

Diffstat:
Mimgurup | 31++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/imgurup b/imgurup @@ -1,9 +1,30 @@ #!/bin/sh -if test -z "$1" -then echo Usage: $(basename $0) image && exit 1 -fi +# upload images to imgur.com +# appends links and deletion links to the log +# depends: curl -APIKEY=486690f872c678126a2c09a9e196ce1b +# check if all args exist as files +for F in "$@"; do + if ! test -f "$F"; then + echo usage: $(basename $0) image ... && exit 1 + fi +done -curl -F "image=@$1" -F "key=$APIKEY" http://api.imgur.com/2/upload.xml +LOG=$HOME/.imgurlog + +# from http://imgur.com/tools/imgurbash.sh +APIKEY='b3625162d3418ac51a9ee805b1840452' + +# upload all +for IMG in "$@"; do + RESP=$(curl -F "image=@$IMG" -F "key=$APIKEY" \ + http://imgur.com/api/upload.xml 2> /dev/null) + + URL=$(echo $RESP | sed 's|.*<original_image>\(.*\)</original_image>.*|\1|') + DELETEURL=$(echo $RESP | sed 's|.*<delete_page>\(.*\)</delete_page>.*|\1|') + + echo "$URL" >> $LOG + echo "$DELETEURL" >> $LOG + echo "$URL" +done