Advertisement
Ford

IMDB Short Plot Version

Apr 16th, 2011
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 12.54 KB | None | 0 0
  1. ;!IMDB Movie Search Script by Ford_Lawnmower irc.GeekShed.net #Script-Help
  2. alias -l IMDB {
  3.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.   ;; Change %tagcolor to the color you want for tags:             ;;
  5.   var %tagcolor $+($chr(15),$chr(2))
  6.   ;; Change %textcolor to the color you want for normal text  ;;
  7.   var %textcolor $+($chr(15),$chr(3),04)
  8.   ;; Change %linkcolor to the color/format you want for links  ;;
  9.   var %linkcolor $+($chr(15),$chr(31))
  10.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
  11.   var %sockname $+(IMDB,$network,$2,$ticks)
  12.   sockopen %sockname www.imdb.com 80
  13.   sockmark %sockname $1-2 $+(/title/,$3,/) 0 %tagcolor %textcolor %linkcolor 0 0
  14. }
  15. menu Channel,Status {
  16.   .$iif($group(#IMDB) == On,$style(1)) IMDB IMDB Trigger
  17.   ..$iif($group(#IMDB) == On,$style(2)) On: .enable #IMDB
  18.   ..$iif($group(#IMDB) == Off,$style(2)) Off: .disable #IMDB
  19. }
  20. #IMDB on
  21. On $*:Text:/^(\+|-|!|@)IMDB.*/Si:#: {
  22.   var %action $regml(1)
  23.   if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
  24.     if (%action == +) {
  25.       if ($istok(%IMDBChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the IMDB script }
  26.       else {
  27.         .enable #IMDB
  28.         Set %IMDBChanList $addtok(%IMDBChanList,$+($network,$chan),32)
  29.         .msg $chan $nick has activated the IMDB script for $chan .
  30.       }
  31.     }
  32.     else {
  33.       if (!$istok(%IMDBChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the IMDB script }
  34.       else {
  35.         Set %IMDBChanList $remtok(%IMDBChanList,$+($network,$chan),1,32)
  36.         .msg $chan $nick has deactivated the IMDB script for $chan .
  37.       }
  38.     }
  39.   }
  40.   elseif (!$timer($+(IMDB,$network,$nick))) && ($istok(%IMDBChanList,$+($network,$chan),32)) {
  41.     .timer $+ $+(IMDB,$network,$nick) 1 6 noop
  42.     var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  43.     GIMDB %method $2-
  44.   }
  45. }
  46. alias EIMDB { GIMDB echo -a $1- }
  47. alias -l GIMDB {
  48.   $1-2 Searching For: $3- .............
  49.   var %sockname $+(GIMDB,$network,$2,$ticks)
  50.   sockopen %sockname www.google.com 80
  51.   sockmark %sockname $1-2 $+(/search?q=,$replace($3-,$chr(32),+),+site:imdb.com&rls=en&hl=en) $3-
  52. }
  53. On *:sockopen:GIMDB*: {
  54.   if (!$sockerr) {
  55.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  56.     sockwrite -n $sockname Host: www.google.com
  57.     sockwrite -n $sockname User-Agent: Opera 9.6
  58.     sockwrite -n $sockname $crlf
  59.   }
  60.   else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  61. }
  62. On *:sockread:GIMDB*: {
  63.   if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  64.   else {
  65.     sockread &GIMDB
  66.     if ($bintween(&GIMDB,Search Results</h2><div id=ires><ol><li class=g><h3 class="r"><a href="http://www.imdb.com/title/,/" class=l,1)) {
  67.       IMDB $gettok($sock($sockname).mark,1-2,32) $v1
  68.       sockclose $sockname
  69.       return    
  70.     }
  71.     elseif ($bintween(&GIMDB,<div id=resultStats>,0 results,1)) {
  72.       $gettok($sock($sockname).mark,1-2,32) Sorry - No cannot find $gettok($sock($sockname).mark,4-,32)
  73.       sockclose $sockname
  74.       return
  75.     }
  76.   }
  77. }
  78. On *:sockclose:GIMDB*: { echo -a sockclose | $gettok($sock($sockname).mark,1-2,32) Sorry - No cannot find $gettok($sock($sockname).mark,4-,32) }
  79. On *:sockopen:IMDB*: {
  80.   if (!$sockerr) {
  81.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  82.     sockwrite -n $sockname Host: www.imdb.com
  83.     sockwrite -n $sockname $crlf
  84.   }
  85.   else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  86. }
  87. On *:sockclose:IMDB*: hfree $sockname
  88. On *:sockread:IMDB*: {
  89.   if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  90.   else {
  91.     var %IMDb | sockread %IMDb
  92.     if ($regex(%imdb,/<title>([^<]*)\s-\sIMDb<\/title>/i)) { hadd -m $sockname title $+($gettok($sock($sockname).mark,5,32),Title:,$chr(32),$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1)) }
  93.     elseif (<span class="title-extra"> isin %imdb) hadd -m $sockname Otitle 1
  94.     elseif ($hget($sockname,Otitle)) {
  95.       hadd -m $sockname title $Xchr(%imdb)
  96.       hadd -m $sockname Otitle 0
  97.     }
  98.     elseif ($regex(%imdb,/([a-z]{6,8}:)/i)) sockmark $sockname $puttok($sock($sockname).mark,$regml(1),4,32)
  99.     elseif (%imdb == <p>) sockmark $sockname $puttok($sock($sockname).mark,shortplot:,4,32)
  100.     elseif (<h2>Storyline</h2> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,plot:,4,32)
  101.     elseif (<table class="cast_list"> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,cast:,4,32)
  102.     elseif (Release Date: isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,date:,4,32)
  103.     elseif ($regex(%imdb,/>([\d\x2C]{1,})\svotes/i)) hadd -m $sockname votes $+($gettok($sock($sockname).mark,5,32),Votes:,$gettok($sock($sockname).mark,6,32)) $regml(1)
  104.     elseif ($gettok($sock($sockname).mark,4,32) == shortplot:) {
  105.       if ($regex(%imdb,/<p>(.*)/i)) hadd -m $sockname shortplot $+($gettok($sock($sockname).mark,5,32),Plot:,$chr(32),$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1))
  106.       sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  107.     }
  108.     elseif ($gettok($sock($sockname).mark,4,32) == runtime:) {
  109.       if (min isin %imdb) {
  110.         hadd -m $sockname runtime $+($gettok($sock($sockname).mark,5,32),Runtime:,$gettok($sock($sockname).mark,6,32)) %imdb
  111.         sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  112.         tokenize 32 $sock($sockname).mark
  113.         hadd -m $sockname link $+($6,$5,Link:,$chr(32),$7,http://www.imdb.com,$3)
  114.         put $1-2 $hget($sockname,title)  $hget($sockname,rating) $hget($sockname,votes) $hget($sockname,genres) $hget($sockname,runtime) $hget($sockname,director) $hget($sockname,writer) $&
  115.         $hget($sockname,language) $hget($sockname,country) $hget($sockname,date) $hget($sockname,shortplot)
  116.         put $1-2 $hget($sockname,cast) $+($hget($sockname,link),$chr(15)) $hget($sockname,trailer)
  117.         hfree $sockname
  118.         sockclose $sockname
  119.         return
  120.       }
  121.     }
  122.     elseif ($gettok($sock($sockname).mark,4,32) == genres:) {
  123.       if ($regex(%imdb,/">([^<]*)<\/a>/g)) hadd -m $sockname genres $+($gettok($sock($sockname).mark,5,32),Genres:,$gettok($sock($sockname).mark,6,32)) $regml(1) $regml(2) $regml(3) $regml(4) $regml(5)
  124.       elseif (</div> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  125.     }
  126.     elseif ($gettok($sock($sockname).mark,4,32) == director:) {
  127.       if ($regex(%imdb,/\/">([^<]*)<\/a>/)) hadd -m $sockname director $+($gettok($sock($sockname).mark,5,32),Director:,$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1))
  128.       elseif (</div> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  129.     }
  130.     elseif ($gettok($sock($sockname).mark,4,32) == writer:) {
  131.       if ($regex(%imdb,/\/">([^<]*)<\/a>/)) hadd -m $sockname writer $+($gettok($sock($sockname).mark,5,32),Writer:,$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1))
  132.       elseif (</div> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  133.     }
  134.     elseif ($gettok($sock($sockname).mark,4,32) == country:) {
  135.       if ($regex(%imdb,/">([^<]*)<\/a>/)) set %IMDb.Country $+($iif(%IMDb.Country,$+($v1,$chr(44))),$Xchr($regml(1)))
  136.       elseif (</div> isin %imdb) {
  137.         sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  138.         hadd -m $sockname country $+($gettok($sock($sockname).mark,5,32),Country:,$gettok($sock($sockname).mark,6,32)) %IMDb.Country
  139.         unset %IMDb.Country
  140.       }
  141.     }
  142.     elseif ($gettok($sock($sockname).mark,4,32) == language:) {
  143.       if ($regex(%imdb,/">([^<]*)<\/a>/)) set %IMDb.Language $+($iif(%IMDb.Language,$+($v1,$chr(44))),$Xchr($regml(1)))
  144.       elseif (</div> isin %imdb) {
  145.         sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  146.         hadd -m $sockname language $+($gettok($sock($sockname).mark,5,32),Language:,$gettok($sock($sockname).mark,6,32)) %IMDb.Language
  147.         unset %IMDb.Language
  148.       }
  149.     }
  150.     elseif ($gettok($sock($sockname).mark,4,32) == plot:) {
  151.       if ($regex(%imdb,/<p>(.*)/)) {
  152.         tokenize 32 $sock($sockname).mark
  153.         hadd -m $sockname plot $6 $+($5,Plot:,$6) $Xchr($regml(1))
  154.         sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  155.       }
  156.     }
  157.     elseif ($gettok($sock($sockname).mark,4,32) == cast: || $gettok($sock($sockname).mark,4,32) == overview:) {
  158.       if ($regex(%imdb,/href="\/name\/.*\/">([^<]*)<\/a>/)) set %IMDb.Cast $+($iif(%IMDb.Cast,$+($v1,$chr(44))),$Xchr($regml(1)))
  159.       elseif (</table> isin %imdb) {
  160.         sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  161.         hadd -m $sockname cast $+($gettok($sock($sockname).mark,5,32),Cast:,$gettok($sock($sockname).mark,6,32)) %IMDb.Cast
  162.         unset %IMDb.Cast        
  163.         tokenize 32 $sock($sockname).mark
  164.         sockmark $sockname $deltok($sock($sockname).mark,10-,32)
  165.       }
  166.     }
  167.     elseif ($gettok($sock($sockname).mark,4,32) == date:) {
  168.       if (</div> isin %imdb) {
  169.         sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  170.         tokenize 32 $sock($sockname).mark
  171.         hadd -m $sockname date $+($5,Release Date:,$chr(32),$6,%IMDb.Date)
  172.         unset %IMDb.Date
  173.       }
  174.       elseif (<span class="see-more inline"> isin %imdb) {
  175.         sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  176.         unset %IMDb.Date
  177.       }
  178.       else set %IMDb.Date %IMDb.Date %imdb
  179.     }
  180.     elseif (watch trailer isin %imdb && $regex(%imdb,/<a\shref="([^<]*)"\sonclick="/)) {
  181.       tokenize 32 $sock($sockname).mark
  182.       hadd -m $sockname trailer $+($5,Trailer:,$chr(32),$7,http://www.imdb.com,$regml(1))
  183.     }
  184.     elseif (<h2>Coming soon</h2> isin %imdb || </html> isin %imdb) {
  185.         tokenize 32 $sock($sockname).mark
  186.         hadd -m $sockname link $+($6,$5,Link:,$chr(32),$7,http://www.imdb.com,$3)
  187.         put $1-2 $hget($sockname,title)  $hget($sockname,rating) $hget($sockname,votes) $hget($sockname,genres) $hget($sockname,runtime) $hget($sockname,director) $hget($sockname,writer) $&
  188.         $hget($sockname,language) $hget($sockname,country) $hget($sockname,date) $hget($sockname,plot)
  189.         put $1-2 $hget($sockname,cast) $+($hget($sockname,link),$chr(15)) $hget($sockname,trailer)
  190.         hfree $sockname
  191.         sockclose $sockname
  192.         return
  193.     }
  194.     elseif ($regex(%imdb,/\|imdb\|([^|]*)\|/)) {
  195.       var %L $round($gettok($regml(1),1,47),0), %R $calc(10 - $round($gettok($regml(1),1,47),0))
  196.       tokenize 32 $sock($sockname).mark
  197.       hadd -m $sockname rating $+($5,Rating:,$chr(32),$5,$chr(91),$6,$str(*,%L),14,$str(*,%R),$5,$chr(93),$6) $regml(1)
  198.     }
  199.   }
  200. }
  201. alias -l AddMark { sockmark $sockname $addtok($sock($sockname).mark,$1-,32) }
  202. alias Xchr {
  203.   var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2});/g,$chr(\1))
  204.   ;Use lines below to make the replace subset
  205.   ;var %sub &ndash; &middot; &raquo; &laquo; &Uuml; &uuml; &Aacute; &aacute; &Eacute; &eacute; &Iacute; &iacute; &Oacute; &oacute; &Ntilde; &ntilde; &Uacute; &uacute;
  206.   ;var %subs – · » « Ü ü Á á É é Í í Ó ó Ñ ñ Ú ú
  207.   ;var %subset $regsubex($str(.,$gettok(%sub,0,32)),/./g,$+($gettok(%sub,\n,32),$chr(44),$gettok(%subs,\n,32),$chr(44)))
  208.   ;echo -a %subset
  209.   return $replacecs(%return,&ndash;,–,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,É,&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,&Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú)
  210. }
  211. alias -l Put {
  212.   if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { return }
  213.   var %tokens $0, %Tstart 4, %Dtimer 1500
  214.   if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  215.   while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
  216.     dec %tokens
  217.     if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
  218.       .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  219.       inc %Dtimer 1500
  220.       %Tstart = $calc(%tokens + 1)
  221.       %tokens = $0
  222.     }
  223.   }
  224.   .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  225.   .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
  226. }
  227. alias -l bintween {
  228.   var %count = 1, %mark = 0, %mark2 = 0
  229.   while (%count <= $4) {
  230.     if ($bfind($1, %mark2, $2).text) {
  231.       %mark = $calc($bfind($1, %mark2, $2).text + $len($2))
  232.       if ($bfind($1, %mark, $3).text) {
  233.         %mark2 = $bfind($1, %mark, $3).text
  234.       }
  235.       else { return 0 }
  236.     }
  237.     else { return 0 }
  238.     inc %count
  239.   }
  240.   return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement