summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Ørsted Andresen <zlin@exherbo.org>2009-12-16 18:18:42 +0000
committerBo Ørsted Andresen <zlin@exherbo.org>2009-12-16 19:17:10 +0000
commit1aadacde298cb33af304462e75f88d2d6feccd17 (patch)
treeb48b7bf3b5db9859eeeca5c8fc48b2b3220d380f
parent9e550207c87ae1019e87f7f05a87fe8c2e3beea2 (diff)
downloadwgetpaste-1aadacde298cb33af304462e75f88d2d6feccd17.tar.gz
Fix tinyurl handling so it uses the api. Make it require exactly one argument as --help suggests.
The API is described at: http://www.scripting.com/stories/2007/06/27/tinyurlHasAnApi.html
-rwxr-xr-xwgetpaste15
1 files changed, 11 insertions, 4 deletions
diff --git a/wgetpaste b/wgetpaste
index eb8eddc..7c049fb 100755
--- a/wgetpaste
+++ b/wgetpaste
@@ -29,7 +29,7 @@ ENGINE_osl=osl
URL_osl="http://pastebin.osuosl.org/ pastebin.php"
# tinyurl
ENGINE_tinyurl=tinyurl
-URL_tinyurl="http://tinyurl.com/ create.php"
+URL_tinyurl="http://tinyurl.com/ api-create.php"
### engines
# ca
@@ -66,9 +66,6 @@ EXPIRATIONS_osl="Never 1%day 1%month"
EXPIRATION_VALUES_osl="f d m"
POST_osl="paste=Send poster % format expiry % code2"
REGEX_RAW_osl='s|^\(http://[^/]*/\)\([0-9]*\)$|\1pastebin.php?dl=\2|'
-# tinyurl
-POST_tinyurl="submit=Make+TinyURL! % % % % % url"
-REGEX_URL_tinyurl='s|^<input type=hidden name=tinyurl value="\?\([^"]*\)"\?>$|\1|p'
### errors
die() {
@@ -525,7 +522,10 @@ while [[ -n $1 ]]; do
TEE=0
;;
-u | --tinyurl )
+ requiredarg "$@"
SERVICE=tinyurl
+ SOURCE="url"
+ INPUTURL="$1"
;;
-v | --verbose )
VERBOSE=0
@@ -656,6 +656,9 @@ fi
# read input
case "$SOURCE" in
+ url )
+ INPUT="${INPUTURL}"
+ ;;
command )
for c in "${COMMANDS[@]}"; do
if [[ $TEE ]]; then
@@ -731,6 +734,9 @@ warnings >&2
# set recipient
RECIPIENT=$(getrecipient RAW)
+if [[ $SERVICE == tinyurl ]]; then
+ URL=$(LC_ALL=C wget -qO - "$RECIPIENT?url=$INPUT")
+else
# create temp file (wget is much more reliable reading
# large input via --post-file rather than --post-data)
[[ -f $TMPF ]] || TMPF=$(mktemp /tmp/wgetpaste.XXXXXX)
@@ -762,6 +768,7 @@ RECIPIENT=$(getrecipient RAW)
# get the url
URL=$(geturl "$OUTPUT")
+fi
# verify that the pastebin service did not return a known error url such as toofast.html from rafb
verifyurl