Hawkee.com snippet searcher and "ripper"

By sunslayer on Sep 27, 2009

Screenshots

there are quite a few snippets on here that search for snippets, but none that actually download and load the code.and that's what this does

paste code in remotes(alt+r) and load it, it will make a directory called Ripz, which is where all the ripped codes will be put
[size=20]Part I[/size]
once you've done that type /rip [-l] snippet number
where the -l switch tells it to load the code once its finished downloading it and snippet number is the number of the snippet e.g., 6749 is the snippet number of http://www.hawkee.com/snippet/6749/
ex:

/rip -l 6749

will download the code and load it

/rip 6749

will jsut download the code
this also adds the original authors name and the name of the snippet to the file
[size=20]Part II[/size]
after loading this snippet right click anywhere in the channel/status window or type /shawk
a dialog will appear, choose the platform you wish to search for and type in some text to search for and then click search.
it will then search hawkee.com and return info about the script that you select.
you can also click "Rip this script" to "rip" the code using the first part of this snippet

on *:load:if (!$isdir(Ripz)) { mkdir Ripz }
alias rip {
  if ($regex($1-,/(-l\W)?(\d*))) {
    sockopen ripz www.hawkee.com 80
    if ($hget(Ripz)) hfree $v1
    hadd -m Ripz snippet $regml($iif($regml(2),2,1))
    hadd Ripz load $iif($regml(2),$true,$false)
  }
  else { echo $color(info) -a * Invalid parameters: /rip [-l] snippet number }
}
on *:sockopen:ripz: {
  sockwrite -n $sockname GET $+(/snippet/,$hget(ripz,snippet),/) HTTP/1.1
  sockwrite -n $sockname HOST: www.hawkee.com $+ $crlf $+ $crlf
}
on *:sockread:ripz: {
  var %ripz | sockread %ripz
  if ($regex(%ripz,/Snippet does not exist./i)) { echo -a * Error: %ripz | sockclose $sockname | .hfree Ripz }
  elseif ($regex(%ripz,/<title>(.+)\x2D.* Code Snippet</title>/)) {
    hadd -m Ripz Name $remove($htmlfree($regml(1)),.,$chr(44))
    if ($isfile($ripz.loc)) { write -c $ripz.loc }
  }
  elseif ($regex(%ripz,/<span style="color: #777; font-size: 11px;">(.*)<\/span>/)) { if ($regml(1) != mIRC Code) { sockclose $sockname | .hfree Ripz | echo -a Error: Snippet not written in MSL } }
  elseif ($regex(%ripz,/<div class="breadcrumb">)) {
    sockread %ripz
    hadd -m Ripz Author $gettok($gettok($htmlfree(%ripz),-2,62),1,39)
  }
  elseif ($regex(%ripz,/<pre class="mirc" style="font-family: Lucida Console. Monaco. Courier;">) && !$sock($Sockname).mark) {
    sockmark $sockname $true
    ripz.write ; $+ $hget(Ripz,name) by: $hget(Ripz,Author)
    ripz.write $htmlfree(%ripz)
  }
  elseif ($sock($sockname).mark && $htmlfree(%ripz)) { 
    ripz.write $v1 
    if ($regex(%ripz,(\W?(</span>\W|&nbsp;)?</pre>|</div)$)) { rip.finish }
  }
  elseif (</form> isin %ripz && $sock($sockname).mark) { rip.finish }
}
alias -l ripz.write write $ripz.loc $1-
alias -l ripz.loc return $qt($+($mircdirRipz\,$hget(Ripz,name),.mrc))
alias -l rip.finish {
  if ($sock(ripz)) sockclose $v1
  if ($isfile($ripz.loc) && $hget(Ripz,load)) { .load -rs $ripz.loc }
  if ($hget(Ripz)) .hfree $v1
  echo -a Rip complete!
}
menu channel,status {
  Hawkee.com Snippet Searcher:shawk
}
alias shawk dialog $+(-,$iif($dialog(shawk),-v,-md shawk)) shawk
dialog shawk {
  title "Hawkee.com Snippet Searcher"
  size -1 -1 151 33
  option dbu
  box "Search", 1, 0 0 151 34
  text "Snippet name:", 2, 4 8 36 8
  edit "", 3, 41 7 106 10
  button "Search", 4, 91 19 32 12
  combo 5, 32 20 50 35, drop
  box "Snippets found", 6, 0 34 151 42
  list 7, 2 43 147 31, size
  box "Snippet Info", 8, 0 76 150 95
  text "Title:", 9, 5 87 14 8
  edit "", 10, 22 86 126 10, read autohs
  text "Description:", 11, 5 111 29 8
  edit "", 12, 36 108 111 16, read vsbar multi
  text "Author:", 13, 5 98 19 8
  edit "", 14, 26 97 50 10, read autohs
  text "Score:", 15, 77 98 17 8
  edit "", 16, 95 97 51 10, read
  text "Platform:", 17, 5 126 24 8
  edit "", 18, 29 125 44 10, read autohs
  text "Likes:", 19, 75 125 15 8
  edit "", 20, 93 125 54 10, read autohs
  text "Date submitted:", 21, 5 137 40 8
  edit "", 22, 47 136 98 10, read autohs
  text "link:", 23, 5 148 10 8
  link "", 24, 19 148 124 8
  button "Rip This Script!", 25, 41 158 65 11
  text "Platform:", 26, 2 22 27 8
}
on *:dialog:shawk:*:*: {
  if ($devent == init) {
    didtok $dname 5 45 .Net-Byond-C++-Cold Fusion-CSS-HI5-IPhone-Java-JavaScript-mIRC-MySpace-MYSQL-OpenSocial-Perl-PHP-Python-Ruby/Rails-TCL
    did -c $dname 5 10
  }
  elseif ($devent == sclick) {
    if ($did == 4) {
      did -r $dname 7
      did -ra $dname 6 Snippets found
      dialog -sb $dname -1 -1 151 33
      if ($hget(Hawkee)) { .hfree -w hawkee* }
      sockopen SHawk www.hawkee.com 80
      var %a = $+(/snippets/search/,$replace($did(3),$chr(32),_)),%b = $+(/cat/,$did(5).seltext,/),%a = $+(%a,%b)
      sockmark SHawk %a
    }
    elseif ($did == 7 && $hget(hawkee. $+ $did($did).sel)) {
      dialog -sb $dname -1 -1 151 171
      var %hash = $v1,%a = 10 14 16 12 18 20 22 24,%b = $hget(%hash,name) ; $hget(%hash,Poster) ; $hget(%hash,Score) ; $iif($hget(%hash,Desc),$v1,No Desc. Available) ; $did(5).seltext ; $iif($hget(%hash,Likes),$v1,0) ; $hget(%hash,Added) ; $+(www.hawkee.com/snippet/,$hget(%hash,Link),/),%c = did -ra $dname,%d = 1
      while ($gettok(%a,%d,32)) { %c $v1 $gettok(%b,%d,59) | inc %d }
    }
    elseif ($did == 24) { url -na $did($did) }
    elseif ($did == 25) { rip $gettok($gettok($did(24),-1,47),1,47) }
  }
  elseif ($devent == close) { sockclose shawk | .hfree -w hawkee* }
}
on *:sockopen:shawk: {
  sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
  sockwrite -n $sockname HOST: www.hawkee.com $+ $crlf $+ $crlf
  sockmark $sockname
}
on *:sockread:shawk: {
  var %shawk,%a | sockread %shawk
  if ($regex(%shawk,/<a href=\x27\/snippet\/(\d*)/\x27.+?>(.+?)<\/a><br>/)) {
    if ($hget(hawkee)) {
      var %a = 1,%b = 1
      while ($hget(Hawkee. $+ %b)) { inc %b }
      while ($hget(Hawkee,%a).item) { hadd -m Hawkee. $+ %b $v1 $hget(Hawkee,%a).data | inc %a }
      .hfree Hawkee
    }
    .hadd -m Hawkee name $regml(2)
    .hadd Hawkee link $regml(1)
  }
  elseif ($regex(%shawk,/<span style=.+>Added\72<\/span>\s(.*)/)) { .hadd Hawkee added $regml(1) }
  elseif ($regex(%shawk,/<span style=.+>By\72<\/span>\s<a href=\x27http:\/\/www\56hawkee\56com\/profile\/\d*\/\x27>(.+?)<\/a><br>/)) { .hadd Hawkee poster $regml(1) | sockread %shawk | .hadd Hawkee Desc $htmlfree(%shawk) }
  elseif ($regex(%shawk,/<span class=.+>(\d*)\slike\x28s\x29<\/span>/)) { .hadd Hawkee Likes $regml(1) }
  elseif ($regex(%shawk,/<span class=.+>Score\72\s<b>(.+?)<\/b><\/span>/)) { .hadd Hawkee score $$regml(1) }
  elseif ($regex(%shawk,/We couldnx27t find any snippets to match your search\56<br> You may also search within the snippet code by choosing \42Code\42 on the right\56/)) { echo -a * No Snippets found! | if ($hget(hawkee)) { .hfree $v1 } | sockclose $sockname }
}
on *:sockclose:shawk: {
  if ($hget(Hawkee)) {
    dialog -sb shawk -1 -1 151 74
    var %a = 1
    while ($hget(Hawkee. $+ %a,name)) { did -a Shawk 7 $v1 | inc %a }
  }
}
alias -l htmlfree { 
  var %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x),%x = $remove(%x,&nbsp;)
  return $regsubex($remove($replace(%x,&quot;,",&lt;,<,&gt;,>,$cr,. $+ $chr(32),$lf,. $+ $chr(32),&amp;,&),$chr(9)),/\46\43(\d*)\73/,$chr(\t)))
}

Comments

Sign in to comment.
sunslayer   -  Apr 11, 2010

it works fine for me Ghost-writer? that screen shot was taken last night...

 Respond  
Ghost-writer   -  Apr 11, 2010

sorry sir, no worky.

 Respond  
Hawkee   -  Apr 11, 2010

It's good to match against the HTML elements at least, for example div id's or classes. That way you don't need to worry about keywords in the description causing unintended matches.

 Respond  
sunslayer   -  Apr 10, 2010

ive simplified the regex a lil to make it more lenient but if you generalize it too much you might get stuck with un-intended matches, i.e. the description could have some info that would match one of the keywords

 Respond  
Hawkee   -  Apr 10, 2010

The problem here is that you're matching all the font and width settings in the CSS. You should generalize your code to match only the key components that likely won't change in the future. Look for things like /snippet/ in the URL or <pre(.*)> excluding all the specifics. It'll work much better in the long run and you won't need to keep changing it.

 Respond  
sunslayer   -  Apr 04, 2010

ye, unfortunately hawkee updated the site again right after i fixed this :@
its a lil late now though, ill update this tomorow

edit: updated

 Respond  
montague   -  Apr 04, 2010

does it still works perfectly? cause mine just PHAIL starting few days ago.. i've tried to upload this cool snippet at another script remote.. but i still got an error.. in the dialog.. it always show up cur in the dialog and i only got 1 input for every search..
d'uh

 Respond  
sunslayer   -  Mar 22, 2010

updated, works again, lol

 Respond  
sunslayer   -  Oct 01, 2009

lol :p

 Respond  
Testor   -  Oct 01, 2009

you = pro :)

 Respond  
Cracker200   -  Oct 01, 2009

Np

 Respond  
sunslayer   -  Sep 30, 2009

thanks :)

 Respond  
Cracker200   -  Sep 30, 2009

OO I like it Nice Work SunSlayer ;)

 Respond  
sunslayer   -  Sep 29, 2009

added a dialog to search for snippets seeing as just the /rip part of this snippet was pretty useless if you have to search for the url anyways

 Respond  
sunslayer   -  Sep 27, 2009

thanks :p

 Respond  
Jethro   -  Sep 27, 2009

Nice work, sunslayer. I like it when you use the word 'rip' lol

 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.