All Movie Searcher v1

By OrFeAsGr on Oct 27, 2016

Hello there!
I know what you're thinking! There's a pretty damn good and famous IMDB script out there!
Well i agree. But i was searching for a movie and the internet lead me to this site and i just had to make a script!
That plus i haven't scripted anything for weeks and i wrote this one in 10 minutes and it worked in the 1st test!
USAGE:

Trigger: !movie
Switches:
-a (all)
-p (people)
-m (movies)

E.g If you want to search for an actor named OrFeAsGr you need to type:
!movie -p OrFeAsGr
If you want to search for a movie named OrFeAsGr (i'm sure they'll make one some day :D ) you need to type
!movie -m OrFeAsGr
If you don't know/care about filtered results type
!movie -a OrFeAsGr

The script will send the 1st result in a channel message and the rest in a private notice to the user! (with a reasonable delay to prevent flood)
Have fun!
(Yes i know it looks a lot like that imDb script!)
Credits to whoever made that $nohtml . Leave a comment if you see this!

The site that is used for this script is www.allmovie.com

;;;;;;;;;;;                               
;;;;;;;;;;;;;;;;;;;;;;          
;;;;;;;;;;;;;;;;;;;;;;;;;;;         
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          
;;;mIRC All Movies Searcher;;;;;;;;;;;;;;    
;;;;;scripted by OrFeAsGr;;;;;;;;;;;;;;;;;;;;;;\   
;;;;;;;;;28/10/2016;;;;;;;;;;;;;;;;;;;;;;;;;;;;/   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;; 
;;;;;;;;;;;
; http://humanity.ucoz.com ;
ON *:TEXT:*:#: {
  tokenize 32 $strip($1-)
  if ($1 == !movie) {
    if ($istok(-a -m -p,$2,32)) {
      set %movie.squery $replace($3-,$chr(32),$+($chr(37),20)) | set %movie.nick $nick | set %movie.chan $chan | set %movie.cat $2
      sockopen allmovie www.allmovie.com 80
    }
    else {
      if (!%movtrigusage) {
        set -u200 %movtrigusage 1
        .notice $nick USAGE: !movie <switch> <search_query> (switches: -a (all results) -m (movies only) -p (people only)
      }
    }
  }
}

ON *:SOCKOPEN:allmovie: {
  sockwrite -nt $sockname GET $+(/search/,$iif(%movie.cat == -a, all, $iif(%movie.cat == -p, people, movies)),/,%movie.squery) HTTP/1.1
  sockwrite -nt $sockname Host: www.allmovie.com  
  sockwrite -nt $sockname User-Agent: Mozilla/4.0
  sockwrite $sockname $crlf
}

ON *:SOCKREAD:allmovie: {
  var %allmovie | sockread %allmovie 
  if (*h1>No search results were found for*</h1* iswm %allmovie) {
    msg %movie.chan $+([,$chr(32),%movie.nick,$chr(32),]) No results were found for your query! Sorry :/ $iif(%movie.cat == -m, Maybe you were looking for a person ( -p ), $iif(%movie.cat == -p, Maybe you were looking for a movie ( -m ), $null)) $iif(%movie.cat != -a, Use -a for both movies and persons results!, $null) 
    unset %movie.*
    sockclose $sockname
  }
  if (*search results for*</h1* iswm %allmovie) {
    tokenize 32 %allmovie
    set %movie.sere $1
  }
  if (*h4>Movie</h4* iswm %allmovie) || (*h4>Person</h4* iswm %allmovie) {
    set %movie.cucat $gettok($gettok(%allmovie,2,62),1,60)
  }
  if (%movie.cucat == Movie) {
    if (*href="http://www.allmovie.com/movie/* iswm %allmovie) {
      set %movie.link $gettok(%allmovie,2,34)
      set %movie.title $gettok($gettok(%allmovie,2,62),1,60)
    }
    if (*irected by:* iswm %allmovie) {
      set %movie.dirlink $gettok(%allmovie,2,34)
      set %movie.dir $gettok($gettok(%allmovie,2,62),1,60)
    }
    if (*http://www.allmovie.com/genre/* iswm %allmovie) {
      var %allmovie = $nohtml($replace(%allmovie,$chr(44),$chr(94)))
      if ($numtok(%allmovie,94)) {
        set %movie.genres $replace(%allmovie,$chr(94),$chr(44))
      }
      elseif (!$numtok(%allmovie,94)) {
        set %movie.genres %allmovie
      }
      inc %movie.count 
      $iif(%movie.count == 1, msg %movie.chan 3< $+(www.allmovie.com,/search/,$iif(%movie.cat == -a, all, $iif(%movie.cat == -p, people, movies)),/,%movie.squery) 3>7 %movie.sere 3Results Found! 1st:, .timer 1 $plusadd(%movie.count) notice %movie.nick $ord(%movie.count))  $iif(%movie.cucat, 7Category:3 $v1, $null) 7Title: %movie.title 3< %movie.link 3> 7Director:3 %movie.dir < %movie.dirlink 3> $replace(%movie.genres,Genres:,$+($chr(03),07,Genres:,$chr(03),03))
      .timerendallmovie off
      .timerendallmovie 1 5 endallmovie
    }
  }
  if (%movie.cucat == Person) {
    if (*http://www.allmovie.com/artist/* iswm %allmovie) {
      set %movie.namelink $gettok(%allmovie,2,34)
      set %movie.name $gettok($gettok(%allmovie,2,62),1,60)
    }
    if (*"years-active"* iswm %allmovie) {
      set %movie.pyears $gettok($gettok(%allmovie,2,62),1,60)
    }
    if (*Notable Work:* iswm %allmovie) {
      set %movie.nworklink $gettok(%allmovie,2,34)
      set %movie.nwork $gettok($gettok(%allmovie,2,62),1,60) $gettok($gettok(%allmovie,4,62),1,60)
      inc %movie.count 
      $iif(%movie.count == 1, msg %movie.chan 3< $+(www.allmovie.com,/search/,$iif(%movie.cat == -a, all, $iif(%movie.cat == -p, people, movies)),/,%movie.squery) 3>7 %movie.sere 3Results Found! 1st:, .timer 1 $plusadd(%movie.count) notice %movie.nick $ord(%movie.count))  $iif(%movie.cucat, 7Category:3 $v1, $null) 7Name:3 %movie.name 3< %movie.namelink 3> 7Years Active:3 %movie.pyears 7Notable Work:3 %movie.nwork < %movie.nworklink 3>
      .timerendallmovie off
      .timerendallmovie 1 5 endallmovie
    }
  }
}

alias nohtml { return $regsubex($1, /<[^>]+(?:>|$)|^[^<>]+>/g,) }

alias endallmovie { 
if (!%movtrigad) {
set -u7200 %movtrigad 1
.timermovtrigad 1 10 msg %movie.chan All Movie Searcher mIRC Script by OrFeAsGr ( http://humanity.ucoz.com )
}
.sockclose allmovie | unset %movie.* 
}

alias plusadd { return $calc($1 + 1) }

Do you want to earn me some cents without paying for anything? Visit http://humanity.ucoz.com after turning your adblock off, watch a short ad by shorte.st and turn it back on.

Or do you want to donate some bucks because you like my scripts??? Visit https://www.paypal.me/OrFeAsGr
Thx! ^_^

Comments

Sign in to comment.
ST3LiST   -  Dec 06, 2016

Nice Script!
You can make it more cool by editing the colour and more detail's to the Search Info~

 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.