tnow imgur can upload from stdin - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 5abaaafcdbe7bf3e2aea979c0c68c7a1c10be65a
(DIR) parent 5023e4301c25b02efc49ce9e53e1da33cc7450c4
(HTM) Author: z3bra <willy@mailoo.org>
Date: Wed, 3 Dec 2014 13:30:30 +0100
now imgur can upload from stdin
Diffstat:
M imgurup | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/imgurup b/imgurup
t@@ -12,20 +12,22 @@ for F in "$@"; do
done
LOG=$HOME/.imgurlog
-CLIP="xsel -p -i"
# from http://imgur.com/tools/imgurbash.sh
APIKEY='b3625162d3418ac51a9ee805b1840452'
+# use stdin if no file provided
+test -z "$@" && FILES='-' || FILES="$@"
+
# upload all
-for IMG in "$@"; do
+for IMG in "$FILES"; 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" | tee $LOG | $CLIP
+ echo "$URL" | tee $LOG
echo "$DELETEURL" >> $LOG
echo "$URL"
done