3 ########################################################
4 # TinyPicUploader (tpu) 0.2 #
5 # Author: Arm the Homeless <ratm@archlinux.us> #
6 # Description: Uploads to TinyPic. Read name. =P #
8 ########################################################
12 Usage: tpu file [file, ...]
14 Uploads files to TinyPic and prints the result urls.
15 If directories are given they will be recursed for images.
23 for each
in $
(ls -d $1/*); do upload
$each; done
24 elif [ -f $1 ] && [ -r $1 ] && [ $
(file -L -b --mime-type $1 |
grep 'image') ]; then
25 timestamp
=$
(date +'%s%N')
26 workfile
="/tmp/tinypic.$timestamp"
27 curl
-L -s -F "the_file=@$1" -F file_type
=image
-F action
=upload
"http://s4.tinypic.com/upload.php" -H "Expect:" -o $workfile
28 uploaded
=$
(grep 'name="pic"' $workfile |
sed 's/.*value="\([^"]*\).*/\1/')
29 if [ $uploaded ]; then
30 ival
=$
(grep 'name="ival"' $workfile |
sed 's/.*value="\([^"]*\).*/\1/')
31 echo "http://i$ival.tinypic.com/$uploaded.jpg"
38 (for arg
in $
*; do upload
$arg; done; echo "-- done --")|zenity
--title="TinyPicUploader" --text-info