!IMDB Movie Search Script

Moderator: GeekShed.Net Staff

!IMDB Movie Search Script

Postby Ford » Wed Oct 28, 2009 1:30 am

This is a nice little script to add to your bot and not the easiest one to write so I thought I'd post it here for anyone who wants to try it.
To use this code:
  • Copy code to clipboard
  • Paste to a NEW remote
  • Save with a unique file name
  • Right click channel or status window
  • Turn IMDB Trigger ON
After the script is loaded and activated the triggers are !imdb moviename or @imdb moviename.
The !imdb trigger will notice the user and the @trigger will message the channel if the user has halfops or higher.
Default response is notice user.

Example use and response:
20:27:51 <Ford> !imdb halloween
20:27:51 -GoogleBoogle- Searching For: halloween
20:27:54 -GoogleBoogle- Title: Halloween (2007) Trailer: http://www.imdb.com/rg/videos-title/gallery-link/title/tt0373883/videogallery User Rating: ********** 6.0/10 Director: Rob Zombie Writer: Rob Zombie Release Date: 31 August 2007 (USA) Genre: Horror
20:27:56 -GoogleBoogle- Tagline: Evil Has A Destiny
20:27:57 -GoogleBoogle- Plot: After being committed for 17 years Michael Myers now a grown man and still very dangerous escapes from the mental institution (where he was committed as a 10 year old) and he immediately returns to Haddonfield where he wants to find his baby sister Laurie. Anyone who crosses his path is in mortal danger.
20:27:58 -GoogleBoogle- User Comments: Way WAY better than I expected
20:27:59 -GoogleBoogle- Cast: Malcolm McDowell Scout Taylor-Compton Tyler Mane Daeg Faerch Sheri Moon Zombie William Forsythe Danielle Harris Kristina Klebe Skyler Gisondo Danny Trejo Hanna Hall Tom Towles http://www.imdb.com/title/tt0373883/
20:28:00 -GoogleBoogle- Language: English Runtime: 109 min USA:121 min (unrated version) Brazil:83 min (cut version) Country: USA
**NOTE**
This script was written specifically for MOVIE searches. It will NOT search TV shows.
Code: Select all
;!IMDB Movie Search Script by Ford_Lawnmower irc.GeekShed.Net #Script-Help
menu Channel,Status {
  .$iif($group(#IMDB) == On,$style(1)) IMDB Trigger
  ..$iif($group(#IMDB) == On,$style(2)) On: .enable #IMDB
  ..$iif($group(#IMDB) == Off,$style(2)) Off: .disable #IMDB
}
#IMDB on
On $*:Text:/^(!|@)IMDB.*/Si:#: {
  if ($timer($+(IMDB,$network,$nick))) { return }
  .timer $+ $+(IMDB,$network,$nick) 1 6 noop
  var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  GIMDB %method $2-
}
#IMDB end
alias EIMDB { GIMDB echo -a $1- }
alias -l GIMDB {
  $1-2 06Searching For:07 $3-
  var %sockname $+(GIMDB,$network,$2,$ticks)
  sockopen %sockname www.google.com 80
  sockmark %sockname $1-2 $+(/search?q=,$replace($3-,$chr(32),+),&btnGNS=Search+imdb.com&oi=navquery_searchbox&sa=X&as_sitesearch=imdb.com&hl=en&rls=en&hs=CVe) $3-
}
On *:sockopen:GIMDB*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.google.com
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:GIMDB*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    sockread &GIMDB
    if ($bintween(&GIMDB,results shown</span><li class=g><h3 class=r><a href="/url?q=,"><em>,1)) {
      IMDB $gettok($sock($sockname).mark,1-2,32) $gettok($v1,4,47)
      sockclose $sockname
      return   
    }
    if ($bintween(&GIMDB,Search Results</h2><div><ol><li class=g><h3 class=r><a href="," class=l><em>,1)) {
      IMDB $gettok($sock($sockname).mark,1-2,32) $gettok($v1,4,47)
      sockclose $sockname
      return
    }
  }
}
On *:sockclose:GIMDB*: { $gettok($sock($sockname).mark,1-2,32) Sorry - No cannot find $gettok($sock($sockname).mark,4-,32) }
alias -l IMDB {
  var %sockname $+(IMDB,$network,$2,$ticks)
  sockopen %sockname www.imdb.com 80
  sockmark %sockname $1-2 $+(/title/,$3,/) 0 0 0 0 0 0
}
On *:sockopen:IMDB*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.imdb.com
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:IMDB*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    sockread -fn &IMDB
    if (User_Comments isin $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        put $gettok($sock($sockname).mark,1-2,32) 06User Comments:07 $Xchr($NoMore($_($gettok($sock($sockname).mark,8,32))))
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }
    }
    if (Trailer == $gettok($sock($sockname).mark,4,32)) && ($bintween(&IMDB,<a href="/rg/videos-title/,",1)) {
      AddMark $+($gettok($sock($sockname).mark,9,32),_,06Trailer:07,_,,http://www.imdb.com/rg/videos-title/,$v1,) 9
      AddMark 0 4
    }
    if (Title == $gettok($sock($sockname).mark,4,32)) && ($bintween(&IMDB,<b>,</b>,1)) {
      AddMark $+(06Title:07,_,$Xchr($_($v1))) 9   
      AddMark 0 4
    }     
    if (Plot == $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        put $gettok($sock($sockname).mark,1-2,32) 06Plot:07 $NoMore($_($gettok($sock($sockname).mark,8,32)))
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }       
    }   
    if (Tagline isin $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        put $gettok($sock($sockname).mark,1-2,32) 06Tagline:07 $NoMore($_($gettok($sock($sockname).mark,8,32)))
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }   
    }   
    if (Release_Date isin $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        AddMark $+($gettok($sock($sockname).mark,9,32),_,06Release_Date:07,_,$NoMore($gettok($sock($sockname).mark,8,32))) 9           
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }       
    }
    if (Language == $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        put $gettok($sock($sockname).mark,1-2,32) 06Language:07 $NoMore($_($gettok($sock($sockname).mark,8,32) $gettok($sock($sockname).mark,9,32)))
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }       
    }
    if (Runtime == $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        AddMark $+(06Runtime:07,_,$gettok($sock($sockname).mark,8,32)) 9
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }       
    }
    if (Country == $gettok($sock($sockname).mark,4,32)) {
      if (</div> isin $bvar(&IMDB,1,$bvar(&IMDB,0)).text) {
        AddMark $+($gettok($sock($sockname).mark,9,32),_,06Country:07,_,$gettok($sock($sockname).mark,8,32)) 9
        AddMark 0 8
        AddMark 0 4
      }         
      if ($httpstrip($bvar(&IMDB,1,$bvar(&IMDB,0)).text)) {
        var %v = $v1
        $iif(!$gettok($sock($sockname).mark,8,32),AddMark $_(%v) 8,AddMark $+($gettok($sock($sockname).mark,8,32),_,$_(%v)) 8)
      }       
    }                 
    if ($bintween(&IMDB,<h5>,:</h5>,1)) { sockmark $sockname $puttok($sock($sockname).mark,$_($v1),4,32) }
    if ($gettok($sock($sockname).mark,4,32) == User_Rating) && ($bintween(&IMDB,<b>,</b>,1)) {
      var %L $round($gettok($v1,1,47),0), %R $calc(10 - $round($gettok($v1,1,47),0))
      AddMark $+($gettok($sock($sockname).mark,9,32),_,06User_Rating:07,_,08,$chr(91),09,$str(*,%L),14,$str(*,%R),08,$chr(93),07,_,$v1) 9
      AddMark 0 4
    }
    if (Director isin $gettok($sock($sockname).mark,4,32)) && ($bintween(&IMDB,/';">,</a>,1)) {
      AddMark $+($gettok($sock($sockname).mark,9,32),_,06Director:07,_,$Xchr($_($v1))) 9   
      AddMark 0 4
    }
    if (Writer isin $gettok($sock($sockname).mark,4,32)) && ($bintween(&IMDB,/';">,</a>,1)) {
      AddMark $+($gettok($sock($sockname).mark,9,32),_,06Writer:07,_,$Xchr($_($v1))) 9       
      AddMark 0 4
    }       
    if ($bintween(&IMDB,<a href="/Sections/Genres/,/">,1)) {
      AddMark $v1 6
      var %c 2
      while (%c < 6) {
        if ($bintween(&IMDB,<a href="/Sections/Genres/,/">,%c)) { AddMark $+($gettok($sock($sockname).mark,6,32),$chr(44),$v1) 6 }
        inc %c
      }
      put $gettok($sock($sockname).mark,1-2,32) $_($httpstrip($gettok($sock($sockname).mark,9,32))) 06Genre:07 $gettok($sock($sockname).mark,6,32)
      AddMark 0 9
    }
    if ($bfind(&IMDB,1,<b>Videos</b>).text) { AddMark Trailer 4 }
    if ($bfind(&IMDB,1,<a href="/">IMDb</a> &gt;).text) { AddMark Title 4 }
    if ($bfind(&IMDB,1,<h3>Cast</h3>).text) { sockmark $sockname $puttok($sock($sockname).mark,Cast,4,32) }
    if ($bfind(&IMDB,1,<!-- sid: test01-channel : MIDDLE_CENTER -->).text) && ($gettok($sock($sockname).mark,7,32)) {
      put $gettok($sock($sockname).mark,1-2,32) 06Cast:07 $_($v1) $+(06,http://www.imdb.com,$gettok($sock($sockname).mark,3,32))
    }
    if ($gettok($sock($sockname).mark,4,32) == Cast) && ($bintween(&IMDB,/';">,</a></td><td class="ddd"> ... ,1)) {
      var %c 2,%v $httpstrip($v1)
      AddMark $iif($gettok($sock($sockname).mark,7,32),$+($gettok($sock($sockname).mark,7,32),$chr(44),$_(%v)),$_(%v)) 7
      while (%c < 11) {
        if ($bintween(&IMDB,/';">,</a></td><td class="ddd"> ... ,%c)) {
          AddMark $+($gettok($sock($sockname).mark,7,32),$chr(44),$_($httpstrip($v1))) 7
          sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32)
          if ($gettok($sock($sockname).mark,5,32) == 10) {
            %c = 10
            addmark 0 5
          } 
        }
        inc %c
      }
    }
  }
}
alias -l NoMore { return $regsubex($1-,/more \(.*total\)$|more[/s]?$|full summary|add synopsis|full synopsis|5af|b63|12a|a9/g,$null) }
alias -l AddMark { sockmark $sockname $puttok($sock($sockname).mark,$1,$2,32) }
alias -l Xchr { return $regsubex($1-,/&#x([A-F.0-9]{1,2});/g,$chr($base($regml(\n),16,10))) }
alias -l _ { return $iif(_ isin $1-,$replace($1,_,$chr(32)),$replace($1-,$chr(32),_)) }
alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) | return $Xchr($remove($replace(%x,&amp;,&,&quot;,"),&nbsp;,&lt;,$chr(124))) }
alias -l bintween {
  var %count = 1, %mark = 0, %mark2 = 0
  while (%count <= $4) {
    if ($bfind($1, %mark2, $2).text) {
      %mark = $calc($bfind($1, %mark2, $2).text + $len($2))
      if ($bfind($1, %mark, $3).text) {
        %mark2 = $bfind($1, %mark, $3).text
      }
      else { return 0 }
    }
    else { return 0 }
    inc %count
  }
  return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text
}
alias -l Put {
  if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { return }
  var %tokens $0, %Tstart 3, %Dtimer 1500
  if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) } 
  while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
    dec %tokens
    if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
      .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
      inc %Dtimer 1500
      %Tstart = $calc(%tokens + 1)
      %tokens = $0
    }
  }
  .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
  .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
}
Ford
 
Posts: 48
Joined: Wed Oct 28, 2009 1:01 am

Re: !IMDB Movie Search Script

Postby therock247uk » Sun Nov 08, 2009 12:46 am

Very nice.
therock247uk
 
Posts: 200
Joined: Thu Oct 22, 2009 8:29 pm
Location: uk

Re: !IMDB Movie Search Script

Postby Ford » Sun Nov 08, 2009 1:47 am

Thanks therock247uk :)
Ford
 
Posts: 48
Joined: Wed Oct 28, 2009 1:01 am

Re: !IMDB Movie Search Script

Postby Pctech37 » Tue Nov 10, 2009 7:44 pm

This script will make your bot flood. Too many lines.
Pctech37
"31337 h4X0rZ" and student
#Pctech37 Founder
Image
Pctech37
 
Posts: 26
Joined: Sat Nov 07, 2009 2:11 am
Location: Everett, Washington, United States of America

Re: !IMDB Movie Search Script

Postby Ford » Wed Nov 11, 2009 11:43 pm

I haven't had any problems with flooding from this script Pctech37 . I have it running in 30 channels on 5 networks with Zero problems from flooding.
The pace of the lines is regulated by My put alias.
Code: Select all
alias -l Put {
  if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { return }
  var %tokens $0, %Tstart 3, %Dtimer 1500
  if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) } 
  while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
    dec %tokens
    if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
      .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
      inc %Dtimer 1500
      %Tstart = $calc(%tokens + 1)
      %tokens = $0
    }
  }
  .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
  .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
}


If the pace of the output is to quick you can adjust it by changing this line -->> inc %Dtimer 1500
To a higher number
Ford
 
Posts: 48
Joined: Wed Oct 28, 2009 1:01 am


Return to Script help

Who is online

Users browsing this forum: No registered users and 1 guest

cron