LGrobert Elite Newbie
Number of posts : 40 Age : 37 Status : Founder Points : 9 Registration date : 2008-09-30
| Subject: torrent search Wed Dec 03, 2008 1:39 pm | |
| type !torrent <word> to find download links.you need utorrent or azureus! - Code:
-
Menu * { NIGathan's !Torrent .Options:torrentopt .Search TPB:torrentseard .Advertise:describe $active is using !Torrent search. }
alias torrentseard { unset %t.* if (%to.optsp != 1) { if ($?!="Show seeds and leechers?" == $true) set %t.switches -s } set %t.resu $?="Find a specific result? $crlf $+ Cancel or leave blank to get the first 3." :one if (%t.resu != $null && %t.resu !isnum) { set %t.resu $?="Invalid input. Must be a number. $crlf $+ Find a specific result? $crlf $+ Cancel or leave blank to get the first 3." | goto one } if (%t.resu) { if (%t.switches) { set %t.switches %t.switches $+ r } else { set %t.switches -r } } set %t.search $?="What would you like to search for? $crlf $+ Leave blank or click cancel to cancel." if (%t.search == $null) { unset %t.* | halt } echo -a torrentsearch: %t.switches %t.resu %t.search torrentsearch %t.switches %t.resu %t.search }
alias torrentopt { dialog -m torrentopts torrentopts if (%to.optsp == 1) did -c torrentopts 1 did -a torrentopts 5 Description did -a torrentopts 5 Seeds did -a torrentopts 5 Leechers/Peers did -a torrentopts 5 Size did -a torrentopts 5 Date did -c torrentopts 5 %to.sort }
dialog torrentopts { title "!Torrent Options" option dbu size 1 1 110 75 check "Always display seeds/leechers?" 1, 2 1 85 10 text "If this is checked the 's' switch will not be necessary. Although if the 's' switch is seen, it will do the opposite." 2, 2 10 110 20 button "Apply", 3, 2 63 55 10, ok button "Cancel", 4, 58 63 50 10, cancel combo 5, 55 40 50 10, drop text "Default sort method:", 6, 3 42 50 10 box "", 7, 1 35 108 18 }
on *:DIALOG:torrentopts:sclick:3: { if ($did(torrentopts,1).state == 1) set %to.optsp 1 else set %to.optsp 0 set %to.sort $replace($did(torrentopts,5).seltext,Description,1,Seeds,2,Leechers/Peers,3,Size,4,Date,5) }
alias torrentsearch { ;window -ak0 @Torrent set %t.search $1- set %t.page 0 set %t.sort $replacex(%to.sort,1,99,2,7,3,9,4,5,5,3) if (%to.optsp == 1) { set %t.seeddis 1 } if ($left($1,1) == -) { set %t.switches $mid($1,2-) set %t.search $2- if (r isin %t.switches) { if ($calc($2 / 31) <= 1) { set %t.tores $2 set %t.resu $2 set %t.search $3- } else if ($calc($2 / 31) > 1) { set %t.page $gettok($calc($2 / 31),1,46) set %t.tores $calc($2 - ( %t.page * 31)) set %t.resu $2 set %t.search $3- } } if (s isin %t.switches) { if (%to.optsp == 1) { set %t.seeddis 0 } else { set %t.seeddis 1 } } if (b isin %t.switches) { if (r isin %t.switches && $2 isnum) { if (* $+ $3 $+ * iswm %to.sorts) { set %t.sort $replace($3,seeds,7,size,5,leechers,9,peers,9,date,3) | set %t.search $4- } else if (%t.chan) msg %t.chan I cannot sort by $3 $+ . I can only sort by: %to.sorts $+ . else echo -a I cannot sort by $3 $+ . I can only sort by: %to.sorts $+ . } else if (r isin %t.switches && $3 isnum) { if (* $+ $2 $+ * iswm %to.sorts) { set %t.sort $replace($2,seeds,7,size,5,leechers,9,peers,9,date,3) | set %t.search $4- } else if (%t.chan) msg %t.chan I cannot sort by $2 $+ . I can only sort by: %to.sorts $+ . else echo -a I cannot sort by $2 $+ . I can only sort by: %to.sorts $+ . if ($calc($3 / 31) <= 1) { set %t.tores $3 set %t.resu $3 } else if ($calc($3 / 31) > 1) { set %t.page $gettok($calc($3 / 31),1,46) set %t.tores $calc($3 - ( %t.page * 31)) set %t.resu $3 } } else if (r !isin %t.switches) { if (* $+ $2 $+ * iswm %to.sorts) { set %t.sort $replace($2,seeds,7,size,5,leechers,9,peers,9,date,3) set %t.search $3- } else if (%t.chan) msg %t.chan I cannot sort by $2 $+ . I can only sort by: %to.sorts $+ . else echo -a I cannot sort by $2 $+ . I can only sort by: %to.sorts $+ . } else { if (%t.chan) msg %t.chan Invalid parameters. else echo -a Invalid parameters. } } } set %t.tor 1 set %t.acheck <h2><span>Search results: * set %t.catcheck <td class="vertTh"><a href="/browse/* set %t.torcheck <td><a href="/torrent/* set %t.link $+(http://thepiratebay.org/search/,$phex(%t.search),/,%t.page,/,%t.sort,/0) set %t.none No hits. Try adding an asterisk set %t.catr $+($chr(38),gt,$chr(59)) set %t.spcheck <td align="right"> sockopen tpb thepiratebay.org 80 sockmark tpb %t.search }
on *:TEXT:!torrent *:#: { set %t.chan $chan torrentsearch $2- }
on *:SOCKOPEN:tpb: { sockwrite -n $sockname GET $+(/search/,$phex($gettok($sock($sockname).mark,1-,32)),/,%t.page,/,%t.sort,/0) HTTP/1.0 sockwrite -n $sockname Host: thepiratebay.org sockwrite $sockname $crlf }
on *:SOCKREAD:tpb: { if ($sockerr) { msg %t.chan Error reading socket info. Please try again. | halt } var %t.sockshit sockread %t.sockshit if (%t.acheck iswm %t.sockshit) { if (%t.none isin %t.sockshit) { msg %t.chan No results found for " $+ %t.search $+ ". Try adding an asterisk to your search phrase. | unset %t.* | halt } set %t.ares $gettok(%t.sockshit,$calc($findtok(%t.sockshit,$chr(40) $+ approx,32)+1),32) } if (%t.ares < 1) { msg %t.chan Thepiratebay.org returned no results for: " $+ %t.search $+ ". | unset %t.* | halt } if (%t.tores == $null) { if ((%t.catcheck iswm %t.sockshit) && %t.tor == 3) { set %t.cat3 $replacex($gettok(%t.sockshit,3,62),%t.catr,$chr(62),</a, ) } if ((%t.torcheck iswm %t.sockshit) && (title="Details isin %t.sockshit) && %t.tor == 3) { set %t.tor3 $replacex($gettok(%t.sockshit,3,62),>,$chr(62),</a, ) set %t.link3 http://thepiratebay.org $+ $gettok(%t.sockshit,2,34) if (%t.seeddis == 1) { set %t.spc 1 set %t.upc 0 } else { inc %t.tor } } if (%t.seeddis == 1) { if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 2) && %t.tor == 3) { set %t.leech3 $remove(%t.sockshit,%t.spcheck,</td>) unset %t.spc unset %t.upc inc %t.tor } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 1) && %t.tor == 3) { set %t.seed3 $remove(%t.sockshit,%t.spcheck,</td>) inc %t.upc } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 0) && %t.tor == 3) { inc %t.upc } } if ((%t.catcheck iswm %t.sockshit) && %t.tor == 2) { set %t.cat2 $replacex($gettok(%t.sockshit,3,62),%t.catr,$chr(62),</a, ) } if ((%t.torcheck iswm %t.sockshit) && (title="Details isin %t.sockshit) && %t.tor == 2) { set %t.tor2 $replacex($gettok(%t.sockshit,3,62),>,$chr(62),</a, ) set %t.link2 http://thepiratebay.org $+ $gettok(%t.sockshit,2,34) if (%t.seeddis == 1) { set %t.spc 1 set %t.upc 0 } else { inc %t.tor } } if (%t.seeddis == 1) { if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 2) && %t.tor == 2) { set %t.leech2 $remove(%t.sockshit,%t.spcheck,</td>) unset %t.spc unset %t.upc inc %t.tor } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 1) && %t.tor == 2) { set %t.seed2 $remove(%t.sockshit,%t.spcheck,</td>) inc %t.upc } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 0) && %t.tor == 2) { inc %t.upc } } if ((%t.catcheck iswm %t.sockshit) && %t.tor == 1) { set %t.cat1 $replacex($gettok(%t.sockshit,3,62),%t.catr,$chr(62),</a, ) } if ((%t.torcheck iswm %t.sockshit) && (title="Details isin %t.sockshit) && %t.tor == 1) { set %t.tor1 $replacex($gettok(%t.sockshit,3,62),>,$chr(62),</a, ) set %t.link1 http://thepiratebay.org $+ $gettok(%t.sockshit,2,34) if (%t.seeddis == 1) { set %t.spc 1 set %t.upc 0 } else { inc %t.tor } } if (%t.seeddis == 1) { if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 2) && %t.tor == 1) { set %t.leech1 $remove(%t.sockshit,%t.spcheck,</td>) unset %t.spc unset %t.upc inc %t.tor } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 1) && %t.tor == 1) { set %t.seed1 $remove(%t.sockshit,%t.spcheck,</td>) inc %t.upc } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 0) && %t.tor == 1) { inc %t.upc } } if (%t.tor == 4 || (%t.sockshit == </html> && %t.tor)) { if (%t.chan != $null) { msg %t.chan Approx. %t.ares $+ Results found for " $+ %t.search $+ " at %t.link $+ . if (%t.seeddis == 1) { if (%t.link1) msg %t.chan Result 1: Cat: %t.cat1 Title: %t.tor1 Seeds: %t.seed1 Leechers: %t.leech1 ( $+ %t.link1 $+ ) if (%t.link2) msg %t.chan Result 2: Cat: %t.cat2 Title: %t.tor2 Seeds: %t.seed2 Leechers: %t.leech2 ( $+ %t.link2 $+ ) if (%t.link3) msg %t.chan Result 3: Cat: %t.cat3 Title: %t.tor3 Seeds: %t.seed3 Leechers: %t.leech3 ( $+ %t.link3 $+ ) } else { if (%t.link1) msg %t.chan Result 1: Cat: %t.cat1 Title: %t.tor1 ( $+ %t.link1 $+ ) if (%t.link2) msg %t.chan Result 2: Cat: %t.cat2 Title: %t.tor2 ( $+ %t.link2 $+ ) if (%t.link3) msg %t.chan Result 3: Cat: %t.cat3 Title: %t.tor3 ( $+ %t.link3 $+ ) } } else { linesep echo -a Approx. %t.ares $+ Results found for " $+ %t.search $+ " at %t.link $+ . if (%t.seeddis == 1) { linesep if (%t.link1) echo -a Result 1: Cat: %t.cat1 Title: %t.tor1 Seeds: %t.seed1 Leechers: %t.leech1 ( $+ %t.link1 $+ ) if (%t.link2) echo -a Result 2: Cat: %t.cat2 Title: %t.tor2 Seeds: %t.seed2 Leechers: %t.leech2 ( $+ %t.link2 $+ ) if (%t.link3) echo -a Result 3: Cat: %t.cat3 Title: %t.tor3 Seeds: %t.seed3 Leechers: %t.leech3 ( $+ %t.link3 $+ ) linesep } else { linesep if (%t.link1) echo -a Result 1: Cat: %t.cat1 Title: %t.tor1 ( $+ %t.link1 $+ ) if (%t.link2) echo -a Result 2: Cat: %t.cat2 Title: %t.tor2 ( $+ %t.link2 $+ ) if (%t.link3) echo -a Result 3: Cat: %t.cat3 Title: %t.tor3 ( $+ %t.link3 $+ ) linesep } } unset %t.* halt } } else { if (%t.resu > %t.ares) { if (%t.chan) { msg %t.chan There were only approx. %t.ares $+ results. Please don't try to search beyond that. } else { linesep | echo -a There were only approx. %t.ares $+ results. Please don't try to search beyond that. | linesep } unset %t.* halt } if (%t.tor > %t.tores) { if (%t.chan) { msg %t.chan Approx. %t.ares $+ Results found for " $+ %t.search $+ " at %t.link $+ . if (%t.seeddis == 1 && %t.link1) { msg %t.chan Result $+ %t.resu $+ : Cat: %t.cat1 Title: %t.tor1 Seeds: %t.seed1 Leechers: %t.leech1 ( $+ %t.link1 $+ ) } else if (%t.link1) { msg %t.chan Result $+ %t.resu $+ : Cat: %t.cat1 Title: %t.tor1 ( $+ %t.link1 $+ ) } } else { linesep echo -a Approx. %t.ares $+ Results found for " $+ %t.search $+ " at %t.link $+ . if (%t.seeddis == 1) { if (%t.link1) { echo -a Result $+ %t.resu $+ : Cat: %t.cat1 Title: %t.tor1 Seeds: %t.seed1 Leechers: %t.leech1 ( $+ %t.link1 $+ ) } } else if (%t.link1) { echo -a Result $+ %t.resu $+ : Cat: %t.cat1 Title: %t.tor1 ( $+ %t.link1 $+ ) } linesep } unset %t.* halt } if (%t.tor == %t.tores) { if (%t.catcheck iswm %t.sockshit) { set %t.cat1 $replacex($gettok(%t.sockshit,3,62),%t.catr,$chr(62),</a, ) } if ((%t.torcheck iswm %t.sockshit) && (title="Details isin %t.sockshit)) { set %t.tor1 $replacex($gettok(%t.sockshit,3,62),>,$chr(62),</a, ) set %t.link1 http://thepiratebay.org $+ $gettok(%t.sockshit,2,34) if (%t.seeddis == 1) { set %t.spc 1 set %t.upc 0 } else { inc %t.tor } } if (%t.seeddis == 1) { if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 2)) { set %t.leech1 $remove(%t.sockshit,%t.spcheck,</td>) unset %t.spc unset %t.upc inc %t.tor } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 1)) { set %t.seed1 $remove(%t.sockshit,%t.spcheck,</td>) inc %t.upc } if ((%t.spcheck isin %t.sockshit) && (%t.spc == 1 && %t.upc == 0)) { inc %t.upc } } } else if (%t.torcheck iswm %t.sockshit) { inc %t.tor } } }
;;$phex borrowed from tye's !google script: http://www.hawkee.com/snippet/14/ alias phex { var %x = 1, %s = $len($1), %r, %w while (%x <= %s) { %w = $mid($1,%x,1) if ($asc(%w) = 32) { %r = $+(%r,+) } elseif ($asc(%w) !isnum 65-90) && ($asc(%w) !isnum 97-122) && ($asc(%w) !isnum 48-57) { %r = $+(%r,%,$base($asc(%w),10,16,2)) } else { %r = $+(%r,%w) } inc %x } return %r }
| |
|