LongURL Shortened URL's Reverser

By _Dean_ on May 27, 2012

This script is made to find out what kind of shortened URL's you're clicking

this script allows you to discover what link you're going to click
looking over 340 URL shortener websites
using the http://longurl.org/ API services

type !reverse URL

check out the total list of websites that longurl.org supports visit http://longurl.org/services

on $*:text:/^!reverse\s(\S+)/iS:#:{
  var %x = $+(reverse,$ticks,$nick)
  $iif($sock(%x), sockclose $v1) 
  sockopen %x api.longurl.org 80
  sockmark %x $regml(1) $chan
}

on *:sockopen:reverse*:{ 
  tokenize 32 $sock($sockname).mark
  if ($sockerr) { msg $2 An error happenned $sock($sockname).wmsg | return }
  else {
    var %x = sockwrite -nt $sockname
    %x GET $+(/v2/expand?url=,$1) HTTP/1.1
    %x Host: api.longurl.org
    %x User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0
    %x 
  }
}

on *:sockread:reverse*:{
  tokenize 32 $sock($sockname).mark
  if ($sockerr) { msg $2 An error happenned $sock($sockname).wmsg | return }
  else {
    var %x
    sockread %x 
    if $regex(%x,/<long-url><!\[CDATA\[(.+)\]\]><\/long-url>/) {
      msg $2 Reversed URL: $regml(1)
    }
    if (*Could not expand* iswm %x) {
      msg $2 Could not expand URL. You probably Posted an Invalid URL or the URL is not supported
      sockclose $sockname
    }
  }
}

Comments

Sign in to comment.
Hawkee   -  May 28, 2012

This can be accomplished without an API by checking the headers after following the link. They're usually just 301 redirects. This is a nice example of API integration though.

 Respond  
SRU   -  May 28, 2012

Like the idea but My "title fetcher" already does this

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.