mIRC Homepage

!Search script for MY music video website

Posted By: ToRmEnTeD

!Search script for MY music video website - 20/10/08 04:21 PM

Hey i have had great sucess finding help here so far so i figured i would drop the big one and see what happens.
I have used irc for a long time and have seen many scripts that search google or other sites and msg the user or channel with results. Well i have a website
www.tormented.tv
Its a database of music videos. I would like a script that would simply run the search on the site and echo results into a msg to the user.
I know i wont get a fast reply on this and im not expecting it. But if a few of you could add your thoughts maybe by the end of it a working script will be posted?
I greatly apprecate anyone who gives this anytime
Posted By: billythekid

Re: !Search script for MY music video website - 21/10/08 06:12 AM

usage /tsearch keyword keyword2 ...

Code:
alias tsearch {
  set %tsearchstring $replace($$1-,$chr(32),+)
  sockopen tsearch tormented.tv 80
}
on 1:sockopen:tsearch:{
  if ($sockerr) { 
    echo 4  -- Socket Error! --
    return
  }
  var %s = sockwrite -n $sockname
  %s GET $+(http://www.tormented.tv/search.php?query=,%tsearchstring,&x=0&y=0&search=1) HTTP/1.1
  %s Referer: tSearch-mIRC-script(User: $+ $me $+ )
  %s Host: tormented.tv
  %s Content-Type: application/x-www-form-urlencoded
  %s Connection: Keep-Alive
  %s Cache-Control: no-cache
  %s
}
on 1:sockread:tsearch:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  if *<b>* - Not Found</b></div>* iswm %temp {
    echo 04 -a $nohtml(%temp)
    sockclose tsearch
unset %tsearch*
  }
  elseif <a href='video.php? isin %temp {
    echo 03 -a $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03)
  }
  elseif *<font face='Georgia'><a href='search.php?query=*&p=2* iswm %temp {
    echo 03 -a More results available try 12http://www.tormented.tv/search.php?query= $+ %tsearchstring $+ &p=203 for more
  }
  elseif %temp { noop }
  else {
    sockclose tsearch
    unset %tsearch*
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}


or if you wanted others to use it they can type !tsearch keywords in channel for you to send them a notice of the results

Code:
on *:text:!tsearch*:#:tsearch $nick $2-
alias -l tsearch {
  set %tsearchnick $1
  set %tsearchstring $replace($$2-,$chr(32),+)
  sockopen tsearch tormented.tv 80
}
on 1:sockopen:tsearch:{
  if ($sockerr) { 
    echo 4  -- Socket Error! --
    return
  }
  var %s = sockwrite -n $sockname
  %s GET $+(http://www.tormented.tv/search.php?query=,%tsearchstring,&x=0&y=0&search=1) HTTP/1.1
  %s Referer: tSearch-mIRC-script(User: $+ $me $+ )
  %s Host: tormented.tv
  %s Content-Type: application/x-www-form-urlencoded
  %s Connection: Keep-Alive
  %s Cache-Control: no-cache
  %s
}
on 1:sockread:tsearch:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  if *<b>* - Not Found</b></div>* iswm %temp {
    notice %tsearchnick 04 $nohtml(%temp)
    sockclose tsearch
unset %tsearch*
  }
  elseif <a href='video.php? isin %temp {
    notice %tsearchnick 03 $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03)
  }
  elseif *<font face='Georgia'><a href='search.php?query=*&p=2* iswm %temp {
    notice %tsearchnick 03 More results available try 12http://www.tormented.tv/search.php?query= $+ %tsearchstring $+ &p=203 for more
  }
  elseif %temp { noop }
  else {
    sockclose tsearch
    unset %tsearch*
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 21/10/08 09:34 AM

wow. Thats just amazing. It works perfect and looks perfect! Thank you soo much! I never thought i would have a working script in my hands so fast. Just simply amazing! smile

Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 21/10/08 09:45 AM

ok this is perfect but the more i play around with it i cant help but think...I also have a guestbook on my site that i have problems getting people to sign....could a piece be added to this where if they did something like !guestbook it would pop up the link to my guestbook like it does a video in the results?
Posted By: billythekid

Re: !Search script for MY music video website - 21/10/08 02:20 PM

yeah you could do a simple

on 1:text:!gb:#:msg $chan http://url.goes.here.com
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 21/10/08 02:44 PM

Yup ....That again works perfect smile thank you
Posted By: billythekid

Re: !Search script for MY music video website - 21/10/08 05:58 PM

You're welcome. I have a standard socket script 'template' sitting here so was just a matter of hitting your site and seeing wht worked. Glad you can use it.

btk
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 03/11/08 11:57 AM

Ok im back but this time with a bit more of a request for an addition to this script or a new one to join it. I am wanting a script that will connect to my site and check for the latest uploaded videos and show a random link of one of the last 3 or 4 videos and display it into the room as a ACTION. Basicly its a way for me to advertise my newest videos and it will put a direct link into the channel like every 15 minutes to one of my pages.

Dont know how hard this will be but i guess we gonna find out smile
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 05/11/08 09:31 PM

Major issues...I just upgraded my site from using flat file database to mysql databace and whatever i did made this script all messed up...anyone able to take a look at it ?
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 07/11/08 05:58 PM

frown Im sooo bummed that this script no longer works.I was getting so many positive comments on it. Upgraded my site from flatfile database to mysql and now it dont work right. when someone
!tsearches anything it just shows like the first few videos in the datebase...like it dont really search at all.....anyways im asking again for anyone that might be able to retweak it for my changes. Wana keep this going cause i really need this script frown

This is the code as is now... (Not working)

Code:
 



on *:text:!tsearch*:#:tsearch $nick $2-
alias -l tsearch {
  set %tsearchnick $1
  set %tsearchstring $replace($$2-,$chr(32),+)
  sockopen tsearch tormented.tv 80
}
on 1:sockopen:tsearch:{
  if ($sockerr) { 
    echo 4  -- Socket Error! --
    return
  }
  var %s = sockwrite -n $sockname
  %s GET $+(http://www.tormented.tv/search.php?query=,%tsearchstring,&x=0&y=0&search=1) HTTP/1.1
  %s Referer: tSearch-mIRC-script(User: $+ $me $+ )
  %s Host: tormented.tv
  %s Content-Type: application/x-www-form-urlencoded
  %s Connection: Keep-Alive
  %s Cache-Control: no-cache
  %s
}
on 1:sockread:tsearch:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  if *<b>* - Not Found</b></div>* iswm %temp {
    notice %tsearchnick 04 $nohtml(%temp)
    sockclose tsearch
unset %tsearch*
  }
  elseif <a href='video.php? isin %temp {
    notice %tsearchnick 03 $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03)
  }
  elseif *<font face='Georgia'><a href='search.php?query=*&p=2* iswm %temp {
    notice %tsearchnick 03 More results available try 12http://www.tormented.tv/search.php?query= $+ %tsearchstring $+ &p=203 for more
  }
  elseif %temp { noop }
  else {
    sockclose tsearch
    unset %tsearch*
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}



Please help if you can.
Posted By: billythekid

Re: !Search script for MY music video website - 29/11/08 05:50 PM

All that had happened was you'd changed your search URL -

it used to be http://www.tormented.tv/search.php?query=,search+here,&x=0&y=0&search=1
but now it's http://www.tormented.tv/search.php?search=,search+here,&x=0&y=0&srch=1

I also added some code to remove the (new?) Featured videos from showing in the results.

Code:
on *:text:!tsearch*:#:tsearch $nick $2-
alias -l tsearch {
  set %tsearchnick $1
  set %tsearchstring $replace($$2-,$chr(32),+)
  sockopen tsearch tormented.tv 80
}
on 1:sockopen:tsearch:{
  if ($sockerr) { 
    echo 4  -- Socket Error! --
    return
  }
  var %s = sockwrite -n $sockname
  %s GET $+(http://www.tormented.tv/search.php?search=,%tsearchstring,&x=0&y=0&srch=1) HTTP/1.1
  %s Referer: tSearch-mIRC-script(User: $+ $me $+ )
  %s Host: tormented.tv
  %s Content-Type: application/x-www-form-urlencoded
  %s Connection: Keep-Alive
  %s Cache-Control: no-cache
  %s
}
on 1:sockread:tsearch:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  ;  echo 04 -s %temp
  if *<b>* - Not Found</b></div>* iswm %temp {
    notice %tsearchnick 04 $nohtml(%temp)
    sockclose tsearch
    unset %tsearch*
  }
  elseif <a href='video.php? isin %temp {
    notice %tsearchnick 03 $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03)
  }
  elseif *<font face='Georgia'><a href='search.php?query=*&p=2* iswm %temp {
    notice %tsearchnick 03 More results available try 12http://www.tormented.tv/search.php?query= $+ %tsearchstring $+ &p=203 for more
  }
  elseif "Featured Videos" isin %temp {
    sockclose tsearch
    unset %tsearch*
  }
  elseif %temp { noop }
  else {
    sockclose tsearch
    unset %tsearch*
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ,$chr(9))
  return %x
}
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 29/11/08 10:45 PM

Ok i think this was an older problem but i apprecate the adding of the featured videos sections part..Yes its new. Lots of new stuff.


I had a problem and someone told me to strip the text or code or whatever and i ended up with this code


Code:
 

on *:text:!tsearch*:#:tsearch $nick $strip($2-)
alias -l tsearch {
  set %tsearchnick $1
  set %tsearchstring $replace($$2-,$chr(32),+)
  sockopen tsearch tormented.tv 80
}
on 1:sockopen:tsearch:{
  if ($sockerr) { 
    echo 4  -- Socket Error! --
    return
  }
  var %s = sockwrite -n $sockname
  %s GET $+(/search.php?search=,%tsearchstring,&srch=1) HTTP/1.1
  %s Referer: tSearch-mIRC-script(User: $+ $me $+ )
  %s Host: tormented.tv
  %s Content-Type: application/x-www-form-urlencoded
  %s Connection: Keep-Alive
  %s Cache-Control: no-cache
  %s
}
on 1:sockread:tsearch:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  if *<b>* - Not Found</b></div>* iswm %temp {
    notice %tsearchnick 04 $nohtml(%temp)
    sockclose tsearch
    unset %tsearch*
  }
  elseif <a href='video.php? isin %temp {
    notice %tsearchnick 03 $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03)
  }
  elseif *<font face='Georgia'><a href='search.php?query=*&p=2* iswm %temp {
  notice %tsearchnick 03 Still want more ? Visit >  12http://www.tormented.tv/search.php?query= $+ %tsearchstring $+ &p=203   }
  elseif %temp { noop }
  else {
    sockclose tsearch
    unset %tsearch*
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}




This works fine for what i need however like you said the featured videos show up sometimes. My problem with this whole script now is that the server has tightened its flood rules and now the script gets the bot kicked everytime it has more than a couple results..any way to limit the number of show results before the link to get more ?
Posted By: billythekid

Re: !Search script for MY music video website - 03/12/08 12:21 PM

you just need to store the results in a file or variable and pass them back using a timer to avoid flooding the server.

If I get a second I'll take a look at it.
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 10/12/08 10:33 AM

Any ideas anyone? frown I sooooo love this script and it suxs to not be able to use it.
Posted By: sparta

Re: !Search script for MY music video website - 10/12/08 12:09 PM

Why not use:
Code:
on *:text:!tsearch*:#:
 if (!%noo.flood) {
 set %no.flood 1
 tsearch $nick $strip($2-)
 .timer 1 20 unset %noo.flood
}

If the variable %noo.flood is set, then the script wont trigger. change the value 20 to what ever you want, now you can use the script every 20 seconds.
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 10/12/08 04:15 PM

Its not that its being used too much...Its that the server we are on now only allows like 7 lines at a time to be put into the channel without being disconnected for flood.

Thats a great and needed feature to be able to prevent users from abusing it once it works the way i need but ...How do i limit the amount of results?
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 10/12/08 04:15 PM

Its not that its being used too much...Its that the server we are on now only allows like 7 lines at a time to be put into the channel without being disconnected for flood.

Thats a great and needed feature to be able to prevent users from abusing it once it works the way i need but ...How do i limit the amount of results?
Posted By: sparta

Re: !Search script for MY music video website - 10/12/08 04:20 PM

Write the info to a text file, then use play to send it? that way you can delay the output..
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 29/12/08 08:49 PM

I still looking for someone to help me with this. I honestly do not understand how to write it to a file ?
Just wanting to keep this going if i can
Posted By: 5618

Re: !Search script for MY music video website - 29/12/08 09:04 PM

Write all the info from the on SOCKREAD event, which you normally send to the person, to a .txt file. E.g...
Code:
elseif (<a href='video.php? isin %temp) { write temp.txt 03 $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03) }

and then where you script terminates, which I assume is...
Code:
else { sockclose tsearch | unset %tsearch* }

...you /play it to the nick...
Code:
else { sockclose tsearch | play -n %tsearchnick temp.txt | unset %tsearch* }
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 30/12/08 04:17 AM

frown Ok .. I dont get what you really mean but then again i cant see your 1st and 3rd example ? idk how to view them like that i guess.
I have ZERO programing abilities other than simple half retarded stuff. I didnt make the script, i am asking for help using it. Maybe if you could repost the examples for me ?
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 06/08/09 11:09 PM

Originally Posted By: ToRmEnTeD


Code:
 

on *:text:!tsearch*:#:tsearch $nick $strip($2-)
alias -l tsearch {
  set %tsearchnick $1
  set %tsearchstring $replace($$2-,$chr(32),+)
  sockopen tsearch tormented.tv 80
}
on 1:sockopen:tsearch:{
  if ($sockerr) { 
    echo 4  -- Socket Error! --
    return
  }
  var %s = sockwrite -n $sockname
  %s GET $+(/search.php?search=,%tsearchstring,&srch=1) HTTP/1.1
  %s Referer: tSearch-mIRC-script(User: $+ $me $+ )
  %s Host: tormented.tv
  %s Content-Type: application/x-www-form-urlencoded
  %s Connection: Keep-Alive
  %s Cache-Control: no-cache
  %s
}
on 1:sockread:tsearch:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  if *<b>* - Not Found</b></div>* iswm %temp {
    notice %tsearchnick 04 $nohtml(%temp)
    sockclose tsearch
    unset %tsearch*
  }
  elseif <a href='video.php? isin %temp {
    notice %tsearchnick 03 $remove($gettok(%temp,6,39),images/,.jpg) (12http://www.tormented.tv/ $+ $gettok(%temp,2,39) $+ 03)
  }
  elseif *<font face='Georgia'><a href='search.php?query=*&p=2* iswm %temp {
  notice %tsearchnick 03 Still want more ? Visit >  12http://www.tormented.tv/search.php?query= $+ %tsearchstring $+ &p=203   }
  elseif %temp { noop }
  else {
    sockclose tsearch
    unset %tsearch*
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}




This works fine for what i need however like you said the featured videos show up sometimes. My problem with this whole script now is that the server has tightened its flood rules and now the script gets the bot kicked everytime it has more than a couple results..any way to limit the number of show results before the link to get more ?


I am once again needing this script and still dont know how to make it write the results to a file as i was sudgested..Anyone able to help me with this for a bit ?
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 07/08/09 09:17 PM

So far this script seems to be working ok as is on my new home network smile
However now i am wanting it to send the results via PM instead of sending the Notice. Anyone able to fix that ?
Posted By: Horstl

Re: !Search script for MY music video website - 07/08/09 09:26 PM

Simply replace the 3 instances of the command (word) "notice" with "msg"
Posted By: ToRmEnTeD

Re: !Search script for MY music video website - 08/08/09 12:10 AM

Ok now i am left with 2 problems.

The first problem is. How do i select how many results are shown before they get the "to see more results click here" msg ?


And my second problem is probably going to be the larger one.

On my site i have a featured video section. For some reason when this script searches my site it includes these featured videos in the results even tho they have nothing to do with whatever was searched for....Is there anyway to solve this issue ?
Anyone think of any other ways to improve the script?
© 2022 mIRC Discussion Forums