From: Sven Hoexter Date: Mon, 17 Jan 2011 17:29:09 +0000 (+0100) Subject: Update mtinyurl.tcl up to version 3 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=a32a20f6d1d6e65851f8c5dbdd819ac5a0e89dd1;p=sven%2Fscripts.git Update mtinyurl.tcl up to version 3 --- diff --git a/home/mtinyurl.tcl b/home/mtinyurl.tcl index 6114129..2618a31 100755 --- a/home/mtinyurl.tcl +++ b/home/mtinyurl.tcl @@ -6,7 +6,7 @@ exec tclsh "$0" ${1+"$@"} # and similar services right away from the command line. # Default is http://jbot.de provided by my friend Ralf. -# Copyright (c) 2007 Sven Hoexter +# Copyright (c) 2007-2010 Sven # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,6 +25,10 @@ exec tclsh "$0" ${1+"$@"} # For updates see http://sven.stormbind.net/misc/ ### Changelog +# Version: 0.3 2010-08-27 +# - Added http://nd.gd as the -n option, currently a pretty stupid +# service which just started linear counting at /01. +# # Version: 0.2 2007-04-17 # - made the service chooseable via cmdline options # - added support for http://jbot.de and made it default @@ -62,6 +66,13 @@ proc use_j {args_j} { maketiny $uri $curlopts $shortname } +proc use_n {args_n} { + set uri http://nd.gd + set curlopts "[http::formatQuery longurl http://$args_n]&OMG%21+SHORT_ME%21" + set shortname "http://nd.gd/" + maketiny $uri $curlopts $shortname +} + proc maketiny {uri curlopts shortname} { global USERAGENT set chandle [curl::init] @@ -95,7 +106,8 @@ proc main {argv0 argv} { #puts "DEBUG: $argv0 -- $argv -- $saneargv" set options { {t.arg -1 "Use http://tinyurl.com service to create a short URL"} - {j.arg -1 "Use http://jbot.de service to create a short URL (default)"} + {j.arg -1 "Use http://jbot.de service to create a short URL (default)"} + {n.arg -1 "Use http://nd.gd service to create a short URL"} } set saneargv0 [::cmdline::getArgv0] set usage "$saneargv0 \[options] URL" @@ -103,6 +115,7 @@ proc main {argv0 argv} { puts $usage puts "-t Use http://tinyurl.com service to create a short URL" puts "-j Use http://jbot.de service to create a short URL (default)" + puts "-n Use http://nd.gd service to create a short URL" exit 1 } @@ -116,8 +129,13 @@ proc main {argv0 argv} { use_j $args(j) } + # Handle -n for http://nd.gd + if {$args(n) != -1} { + use_n $args(n) + } + # No option given? Fall back to a default service (jbot.de) - if {$args(j) == -1 && $args(t) == -1} { + if {$args(j) == -1 && $args(t) == -1 && $args(n) == -1} { use_j $saneargv }