GetImage File Downloading Alias

By FordLawnmower on Jul 25, 2010

Simple file downloading alias. Very handy if you need to download images or files for your snippets.

Syntax:
/GetImage sitename FullPathtoFile DestinationDirectory OutputFilename
Example:
To download this file to images directory:
http://www.hawkee.com/images/noscreen.gif
/GetImage www.hawkee.com /images/noscreen.gif images noscreen.gif

I thought I already posted this but I must have deleted it ;/

;GetImage by Ford_Lawnmower irc.mindforge.org #Technical
;GetImage sitename.com /getdirectory/filename.ext destinationdir outputname.ext
alias GetImage {
  echo -a Downloading $nopath($2) from $1 ................
  if ($isfile($qt($+($3,\,$4)))) { .remove $qt($+($3,\,$4)) }
  var %sockname $+(GetImage,$ticks,$r(1,$ticks))
  if (!$isdir($qt($3))) { mkdir $qt($3) }
  sockopen %sockname $1 80
  sockmark %sockname $1-
}
On *:sockopen:GetImage*:{
  sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.0
  sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) $+ $crlf $+ $crlf
}
On *:sockread:GetImage*:{
  if (!$gettok($sock($sockname).mark,5,32)) {
    var %GetImage | sockread %GetImage
    if (!%GetImage) { sockmark $sockname $addtok($sock($sockname).mark,1,32) }
  }
  else {
    sockread &GetImage
    bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &GetImage
  }
}
On *:sockclose:GetImage*: { echo -a Download of $nopath($gettok($sock($sockname).mark,2,32)) Complete }

Comments

Sign in to comment.
Aucun50   -  Jul 26, 2010

Very Handy :)

 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.