Upload to dropbox with alfred and yourls

Yesterday I started to use alfred a bit more intensive.

I just tried this script to upload files with alfred to dropbox and get a short url from CloudApp. It worked, but I wanted to use it with yourls and not with CloudApp.

So I edited the script to work with yourls, but I run into a bug of yourls.

After fixing the functions.php, everything works great.

Here is the changed code:

#Change This to your Dropbox UserID
DROPBOX_ID=""
YOURLS_USER=""
YOURLS_PW=""

INPUT="{query}"
FILE=`basename "$INPUT"`
ENCODED_FILENAME=${FILE// /%20}
DROPBOX_URL="http://dl.dropbox.com/u/$DROPBOX_ID/$ENCODED_FILENAME"

cp "$INPUT" ~/Dropbox/Public/

LINK=$(curl -G "http://k.nud.ms/yourls-api.php?username=$YOURLS_USER&password=$YOURLS_PW&action=shorturl&format=simple&url=$DROPBOX_URL")

echo $LINK | tr -d '\n' | pbcopy