mIRC Home    About    Download    Register    News    Help

Print Thread
#190343 19/11/07 01:52 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
im looking for a way to get info from www.imdb.com
let's say i have this :
American.Gangster-TEST

on irc

is there a way to make it search on www.imdb.com for "American Gangster"
and return the Rating and Votes to %rating and %votes
so i can process it further in a script

/bwuser

bwuser #190389 20/11/07 04:44 AM
Joined: Jul 2007
Posts: 19
O
Old Offline
Pikka bird
Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
A quick search came up with

http://www.mircscripts.org/comments.php?cid=1405

I haven't tested out the script personally but, you might like to test it out yourself and see if it's what you're looking for.


http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne
Old #190466 21/11/07 10:03 AM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
Code:
;===================================================
; IMDb Movie Search v1.9 by Meij <meijie@gmail.com>
;===================================================

on *:LOAD: {
  if ($version < 6.03) {
    .unload -rs $+(",$script,")
    echo -ts IMDb Movie Search v1.9 Requires mIRC v6.03 or newer to be installed successfully, script auto-unloaded.
  }
  else { echo -ts IMDb Movie Search v1.9, Successfully loaded - Type /_imdb to configure. }
}
on *:UNLOAD: {
  if ($timer(_imdb)) { .timer_imdb off }
  unset %queue._imdb.*
  hfree -w _imdb.*
  echo -ts IMDb Movie Search v1.9, Successfully unloaded.
}
on *:TEXT:*:#: { if ($_ban($+($nick,!,$address))) && ($_trigger($1)) { _input $chan $cid $nick $2- } }
on *:INPUT:#: { if ($_trigger($1)) { _input $chan $cid $nick $2- } }
on *:SOCKOPEN:_imdb.*: {
  tokenize 32 $sock($sockname).mark
  if ($1 == 0) { var %u = $+(/find?s=,$iif($6,nm,tt),&q=,$_encode($8-)) }
  elseif ($7) { var %u = $remove($7,http://www.imdb.com) }

  sockwrite -nt $sockname GET %u HTTP/1.0
  sockwrite -nt $sockname Accept-Language: en-us
  sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
  sockwrite -nt $sockname Referer: http://www.imdb.com/search
  sockwrite -nt $sockname Host: www.imdb.com
  sockwrite -nt $sockname Connection: keep-alive
  sockwrite -t $sockname $str($crlf,2)
}
on *:SOCKREAD:_imdb.*: {
  if ($sockerr > 0) return
  :nextread
  sockread &x
  if ($sockbr == 0) return
  if ($bvar(&x, 1, 7).text == HTTP/1.) {
    var %r $bvar(&x, 1, $calc($bfind(&x, 1, $cr) - 1)).text
    if ($gettok(%r, 2, 32) != 200) && ($gettok(%r, 2, 32) != 302) {
      _hadd $sockname error %r
      _parse $sockname error $sock($sockname).mark
      sockclose $sockname
      return
    }
  }
  if ($bfind(&x,1,$crlf $+ Location:) > 0) {
    if ($regex($bvar(&x,$ifmatch,800).text, Location: (.[^ $+ $crlf $+ ]+))) {
      tokenize 32 $sock($sockname).mark
      if ($hget($sockname)) { if ($hget($sockname)) { hfree $sockname } }
      sockclose $sockname
      sockmark $_open $iif($6,3,1) $2 $3 $4 $5 $6 $gettok($regml(1),1,63) $8-
      return
    }
  }
  hadd -mbu300 $sockname $_item($sockname) &x
  if ($bfind(&x, 1, </html>)) { var %sn $sockname, %sm $sock(%sn).mark | sockclose $sockname | _main %sn %sm | return }
  goto nextread
}
on *:SOCKCLOSE:_imdb.*: { _main $sockname $sock($sockname).mark | return }

;
; Main HTML Parsing Alias
;
alias -l _main {
  var %i 1, %sn $1
  bunset &x
  while ($hget(%sn,%i).item) {
    .echo -q $hget(%sn,%i,&x.d)
    bcopy &x $calc($bvar(&x,0) + 1) &x.d 1 -1
    inc %i
  }
  bunset &x.d
  if ($hget(%sn)) { hfree %sn }
  if ($bvar(&x,0) == 0) {
    _hadd %sn error No data received on socket!
    _parse %sn error $2-
    sockclose %sn
    return
  }
  tokenize 32 $2-
  if ($1 == 0) {
    var %i 0, %p = $bfind(&x, 1, <table>)
    while ($regex(one, $bvar(&x, %p, 850).text, <td valign="top">.*?<br><a href="(.[^"]+)".*?>(.[^<]+)</a>(.*?\x28.[^\x2C]+|.[^<]*).*?<br>)) {
      inc %i
      if (!$5) {
        if ($hget(%sn)) { hfree %sn }
        sockmark $_open $iif($6,3,1) $2 $3 $4 $5 $6 $+(http://www.imdb.com,$gettok($regml(one, 1),1,63)) $8-
        return
      }
      else {
        _hadd %sn num %i
        _hadd %sn title $_regexp($regml(one, 2))
        _hadd %sn url http://www.imdb.com $+ $gettok($regml(one, 1),1,63)
        _hadd %sn year $iif($remove($regml(one, 3),$chr(40),$chr(41),$chr(32),<small>),$ifmatch,n/a)
        _parse %sn list $1-
      }
      if ($5 == %i) { break }
      var %p = $bfind(&x, $calc(%p + 10), <tr>)
    }
    if (%i == 0) { _parse %sn none $1- }
    elseif (%i != $5) {
      _hadd %sn found %i
      _parse %sn miss $1-
    }
  }
  elseif ($1 == 1) {
    var %p = $bfind(&x, 1, <title>)
    if ($regex($bvar(&x, %p, 100).text, <title>(.[^<]*)</title>)) {
      _hadd %sn title $_regexp($regml(1))
      _hadd %sn url $7
      _hadd %sn rating Awaiting 5 votes.
      _hadd %sn rating_votes 0 votes
      _hadd %sn rating_bar
      _hadd %sn rating_extra
    }
    var %p = $bfind(&x, %p, <div id="tn15rating)
    if ($regex(one, $remove($bvar(&x, %p, 850).text, $cr, $lf), <div id="tn15rating".[^>]*>(.+?)</a></div></div>)) {
      if ($regex(one, $regml(one, 1), <b>([0-9\.]+)/10</b> .*?<small>\(<a href="ratings">(.*?)</a>\)</small>(?:.*?<a href=".[^"]+">(.+?)</a>|))) {
        _hadd %sn rating_bar $_rating($regml(one, 1))
        _hadd %sn rating $+($regml(one, 1),/10)
        _hadd %sn rating_votes $regml(one, 2)
        _hadd %sn rating_extra $iif($regml(one, 3), - $_regexp($replace($regml(one, 3), top, Top, bottom, Bottom, ffb,)))
      }
    }
    var %p = $bfind(&x, %p, <h5>)
    while ($regex(one, $remove($bvar(&x, %p, 850).text, $cr, $lf), <h5>(.+?)</h5>)) {
      var %t = $replace($lower($remove($_regexp($regml(one, 1)),:)), $chr(32), _), %m
      if ($regex(one, $remove($bvar(&x, %p, 850).text, $cr, $lf), </h5>(.+?)(?:</div>|<br/><br/>))) {
        if (%t == writing_credits) || (%t == directed_by) {
          var %m = $replace($regml(one, 1), <br/><a, $+($chr(32),/,$chr(32),<a))
          _hadd %sn %t $_regexp(%m)
        }
        else {
          _hadd %sn %t $_regexp($regml(one, 1))
        }
      }
      var %p = $bfind(&x, $calc(%p + 1), <h5>)
    }
    _parse %sn movie $1-
  }
  elseif ($1 == 3) {
    var %p = $bfind(&x, 1, <title>)
    if ($regex($bvar(&x, %p, 100).text, <title>(.[^<]*)</title>)) {
      _hadd %sn name $_regexp($regml(1)) 
      _hadd %sn url $7
    }
    var %p = $bfind(&x, %p, <h5>)
    while ($regex($remove($bvar(&x, %p, 800).text, $cr, $lf), <h5>(.[^<]*)</h5>(.*?)</div>)) {
      var %m = $replace($lower($replace($remove($regml(1), :), Date of birth (location), Date of Birth, biography, Biography)),$chr(32),_)
      _hadd %sn %m $_regexp($regml(2))
      var %p = $bfind(&x, $calc(%p + 1), <h5>)
    }
    _parse %sn cast $1-
  }
}

;
; Main Input Alias
;
alias -l _input {
  if (!$_chan($1)) || (!$_ini(set, online)) { return }
  var %l 0, %c 0, %i 1
  while (%i <= $calc($0 - 3)) {
    var %m = $gettok($4-,%i,32)
    if (($left(%m,2) iswm -l) && ($right(%m,-2) isnum)) { var %l $right(%m,-2) }
    elseif (%m == -c) { var %c 1 }
    else { break }
    inc %i
  }
  var %t = $gettok($4-, $+(%i,-), 32)
  if (!%t) {
    _msg $1 $2 $3 3 $decode(AklNRGIgTW92aWUgU2VhcmNoIHYxLjkCIGJ5IE1laWogPG1laWppZUBnbWFpbC5jb20+,m)
    _msg $1 $2 $3 3 $eval($decode(AlVzYWdlAjogJF9pbmkoc2V0LCB0cmlnZ2VyKSBbb3B0aW9uc10gPHNlYXJjaD4=,m),2)
    _msg $1 $2 $3 3 $decode(Ak9wdGlvbnMCOg==,m)
    _msg $1 $2 $3 3 $decode(AiACIAIgAiACIAJMaXN0IFJlc3VsdHM6IC1sTiAod2hlcmUgTiBpcyB0aGUgbnVtYmVyIG9mIHJlc3VsdHMgdG8gbGlzdCk=,m)
    _msg $1 $2 $3 3 $decode(AiACIAIgAiACIAJDYXN0ICYgQ3JldzogLWMgKHNlYXJjaCBmb3IgYWN0b3JzL2FjdHJlc3Nlcy9maWxtIG1ha2VycyBhbmQgY3Jldyk=,m)
    _msg $1 $2 $3 3 $eval($decode(AkV4YW1wbGUCOiAkX2luaShzZXQsIHRyaWdnZXIpIC1jIC1sNSBLZWlyYQ==,m),2)
    return
  }
  if ($_ini(set, max) < %l) { var %l $ifmatch }

  ; Format:
  ;  1 = what part are we up to
  ;     0 = listing results
  ;     1 = movie info
  ;     2 = extended movie info (not added yet)
  ;     3 = cast / crew info
  ;  2 = channel the trigger was activated from
  ;  3 = network scid
  ;  4 = nickname of the person who activated it
  ;  5 = how many results to list (1, this is default)
  ;  6 = get cast and crew info (0 = get movie info, this is default)
  ;  7 = used for passing urls between events (0 = defualt)
  ;  8 = search string
  sockmark $_open 0 $1 $2 $3 %l %c 0 %t
}

;
; Queue Aliases
;
alias -l _msg {
  set %queue._imdb. [ $+ [ $calc($_info(0) + 1) ] ] $1-
  if (!$timer(_imdb)) { .timer_imdb -m 0 2000 _say }
}
alias -l _info {
  if ($1 isnum) {
    if (%queue._imdb. [ $+ [ $1 ] ]) && ($1 > 0) { return %queue._imdb. [ $+ [ $1 ] ] }
    elseif ($1 == 0) { return $var(%queue._imdb.*) }
  }
}
alias -l _say {
  var %i 1
  if (%queue._imdb. [ $+ [ %i ] ]) {
    tokenize 32 %queue._imdb. [ $+ [ %i ] ]
    scid $2
    if ($3 ison $1) && ($me ison $1) && ($5) {
      if ($4 == 1) { msg $1 $5- }
      elseif ($4 == 2) { .msg $3 $5- }
      else { .notice $3 $5- }
    }
    unset %queue._imdb. [ $+ [ %i ] ] | var %h $calc(%i + 1)
    while (%queue._imdb. [ $+ [ %h ] ]) { set %queue._imdb. [ $+ [ $calc(%h - 1) ] ] %queue._imdb. [ $+ [ %h ] ] | unset %queue._imdb. [ $+ [ %h ] ] | inc %h }
  }
  else { .timer_imdb off }
}

;
; Socket Aliases
;
alias -l _open {
  :name
  var %s = $+(_imdb.,$md5($ticks))
  if ($sock(%s)) { goto name }
  if ($_ini(set, proxy)) {
    if ($_ini(set, host)) && ($_ini(set, port)) { sockopen %s $_ini(set, host) $_ini(set, port) }
    else { echo -ta [IMDb] Error: please specify a hostname and port number in the proxy settings }
  }
  else { sockopen %s www.imdb.com 80 }
  return %s
}

;
; Misc Aliases
;
alias -l _ban {
  var %i 1
  while (%i <= $ini($scriptdirimdb.set, ban, 0)) {
    var %x = $readini($scriptdirimdb.set, n, ban, $ini($scriptdirimdb.set, ban, %i))
    if ($1 isnum) && ($1 == %i) { return %x }
    elseif (%x iswm $1) { return 0 }
    inc %i
  }
  return $iif($1 == 0,$calc(%i - 1), 1)
}
alias -l _item {
  var %i 1
  while ($hget($1,%i).item) { inc %i }
  return %i
}
alias -l _rating {
  var %s = $ceil($1), %i 1
  while (%i <= 10) { if (%i <= %s) { var %z $+(%z,7*) } | else { var %z $+(%z,14*) } | inc %i }
  return $+(11[,%z,11])
}
alias -l _regexp {
  var %i 1, %l quot 34|lt 60|lg 62|amp 38|nbsp 32, %m $1
  while ($regex(two, %m, /(&#(\d{1,3});)/s)) { var %m = $replace(%m, $regml(two, 1), $chr($regml(two, 2))) }
  .echo -q $regsub(%m, /(\.\.\. \/ |\.\.\. |\/ |)<a class="tn15more[^"]*"[^>]*>more</a>/g,, %m)
  .echo -q $regsub(%m, /<[^>]+>/g,, %m)
  while (%i <= $gettok(%l,0,124)) {
    var %t = $gettok(%l,%i,124)
    .echo -q $regsub(%m, $+(/&,$gettok(%t,1,32),;/g), $chr($gettok(%t,2,32)), %m)
    inc %i
  }
  .echo -q $regsub(%m, /&[^;]+;/g,, %m)
  return $remove(%m, (show more), (WGA), (view trailer))
}
alias -l _mode { return $iif($_ini(set, msgmode), $ifmatch, 1) }
alias -l _encode {
  var %s, %p = $len($1-)
  while (%p) {
    if ($mid($1-,%p,1) isalnum) { %s = $+($ifmatch,%s) }
    else { %s = $+(%,$base($asc($mid($1-,%p,1)),10,16),%s) }
    dec %p
  }
  return %s
}
alias -l _ini {
  if ($isid) { return $readini($scriptdirimdb.set, n, $1, $$2) }
  elseif ($3) { writeini $+(",$scriptdir,imdb.set,") $1 $2 $$3- }
  else { remini $+(",$scriptdir,imdb.set,") $$1 $2 }
}
alias -l _trigger {
  if ($1 == $_ini(set, trigger)) { return 1 }
  return 0
}
alias -l _chan {
  if ($_ini(set, all)) { return 1 }
  var %i 1, %l $_ini(set, networks)
  while (%i <= $gettok(%l, 0, 44)) {
    var %n = $gettok(%l, %i, 44)
    if (%n == $network) {
      var %j 1
      while (%j <= $gettok($_ini(set, $+(.,%n)), 0, 44)) {
        var %c = $gettok($_ini(set, $+(.,%n)), %j, 44)
        if (%c == $1) { return 1 }
        inc %j
      }
    }
    inc %i
  }
}

;
; Output Parsing Aliases
;
alias -l _mini {
  var %i 1, %l
  while (%i <= $ini($scriptdirimdb.set, $1, 0)) {
    var %m = $ini($scriptdirimdb.set, $1, %i)
    if ($iif($3,$3-,*) iswm %m) { var %l = $addtok(%l, %m, 44) }
    inc %i
  }
  var %l = $sorttok(%l, 44)
  return $iif($2 == 0, $gettok(%l, 0, 44), $gettok(%l, $2, 44))
}
alias -l _hadd { hadd -mcu300 $1 $$2 $3- }
alias -l _codes {
  var %i 1, %o $$1-, %r = $+(/&b\^/g 2|/&u\^/g 31|/&o\^/g 15|/&k\^/g 3|/&r\^/g 22)
  while (%i <= $gettok(%r, 0, 124)) {
    var %t = $gettok(%r, %i, 124)
    .echo -q $regsub(%o, $gettok(%t, 1, 32), $iif($gettok(%t, 2, 32) isnum, $chr($ifmatch), $ifmatch), %o)
    inc %i
  }
  return %o
}
alias -l _parse {
  var %i 1, %m $+($2,_*), %s $3-
  _hadd $1 chan $gettok(%s, 2, 32)
  _hadd $1 nick $gettok(%s, 4, 32)
  _hadd $1 limit $gettok(%s, 5, 32)
  _hadd $1 search $gettok(%s, 8-, 32)
  while (%i <= $_mini(outp, 0, %m)) {
    var %e = $_mini(outp, %i, %m), %l = $_codes($_ini(outp, %e)), %j 1, %o %l
    while (%j <= $hget($1, 0).item) {
      .echo -q $regsub(%o, $+(/&,$hget($1, %j).item,\^/g), $hget($1, $hget($1, %j).item), %o)
      inc %j
    }
    inc %i
    if ($regex(%l, /&[^&]*?\^/g) != $regex(%o, /&[^&]*?\^/g)) {
      .echo -q $regsub(%o,/&[^&]*?\^/g,n/a, %o)
      _msg $gettok(%s, 2, 32) $gettok(%s, 3, 32) $gettok(%s, 4, 32) $_mode %o
    }
  }
  if ($hget($1)) { hfree $1 }
}

;
; Dialog Stuff
;
alias _imdb { if (!$dialog(_imdb)) { dialog -m _imdb _imdb } }
alias -l _cmbload {
  var %i 1
  while (%i <= $gettok($_ini($3, $4),0,44)) {
    did -a $1 $2 $gettok($_ini($3, $4),%i,44)
    inc %i
  }
}
alias -l _cmbsave {
  var %i 1, %j
  while ($did($1,$2,%i).text) {
    var %j = $+($iif(%j,$+(%j,$chr(44))),$did($1,$2,%i).text)
    inc %i
  }
  return %j
}
alias -l _replace { return $replace($$1-, $chr(2), &b^, $chr(31), &u^, $chr(15), &o^, $chr(3), &k^, $chr(22), &r^)) }
dialog _imdb {
  title "IMDb Movie Search - Settings [/_imdb]"
  size -1 -1 190 102
  option dbu
  combo 5, 0 9 60 72, sort size
  combo 1, 61 9 61 72, sort size
  button "Done", 2, 74 93 37 9, ok cancel
  edit "", 3, 127 37 60 10
  text "Trigger:", 4, 127 30 20 7
  text "Channels", 6, 80 1 23 7
  text "Networks", 7, 18 1 24 7
  button "Add", 8, 61 81 16 9
  button "Rem", 9, 78 81 16 9
  button "Add", 10, 0 81 16 9
  button "Rem", 11, 17 81 16 9
  check "All", 16, 106 81 17 10
  check "Enable Script", 15, 128 48 46 9
  combo 12, 127 19 60 43, size drop
  box "Options", 13, 124 6 66 85
  text "Message Mode", 14, 127 12 37 7
  button "Ban List", 20, 127 59 60 9
  button "Proxy Settings", 17, 127 69 60 9
  button "Configure Output", 18, 127 79 60 9
}
dialog _imdb.proxy {
  title "IMDb Movie Search - Proxy Settings"
  size -1 -1 164 19
  option dbu
  button "Done", 1, 62 10 37 9, ok cancel
  text "Host:", 2, 0 1 14 8, right
  edit "", 3, 15 0 102 10
  text "Port:", 4, 118 1 13 8, right
  edit "", 5, 132 0 31 10
  check "Enabled", 6, 133 10 30 9
}
dialog _imdb.ban {
  title "IMDb Movie Search - Ban List"
  size -1 -1 190 102
  option dbu
  combo 1, 1 1 188 92, size
  button "Done", 2, 74 93 37 9, ok cancel
  button "Add", 3, 0 93 16 9, default
  button "Rem", 4, 17 93 16 9
}
dialog _imdb.output {
  title "IMDb Movie Search - Configure Output"
  size -1 -1 190 102
  option dbu
  edit "", 1, 0 12 190 80, multi return autohs autovs vsbar
  combo 2, 1 1 60 50, size drop
  text "", 3, 136 3 51 8, hide
  button "Done", 4, 74 93 37 9, ok cancel
}
on *:DIALOG:_imdb:*:*: {
  if ($devent == init) {
    if ($_ini(set, online)) { did -c $dname 15 }
    did -a $dname 12 Channel
    did -a $dname 12 Private
    did -a $dname 12 Notice
    did -c $dname 12 $iif($_ini(set, msgmode),$ifmatch,1)
    did -ra $dname 3 $_ini(set, trigger)
    _cmbload $dname 5 set networks
    if ($_ini(set, all)) { did -c $dname 16 | did -b $dname 1,5,8,9,10,11 }
    else { did -c $dname 5 1 }
    if ($did($dname,5,1).text) {
      _cmbload $dname 1 set . $+ $did($dname,5,1)
    }
  }
  if ($devent == sclick) {
    if ($did == 19) { run $did($dname,19).text }
    if ($did == 17) { if (!$dialog(_imdb.proxy)) { dialog -ma _imdb.proxy _imdb.proxy } }
    if ($did == 20) { if (!$dialog(_imdb.ban)) { dialog -ma _imdb.ban _imdb.ban } }
    if ($did == 18) { if (!$dialog(_imdb.output)) { dialog -ma _imdb.output _imdb.output } }
    if ($did == 12) { _ini set msgmode $did($dname,12).sel }
    if ($did == 15) { _ini set online $did($dname,15).state }
    if ($did == 16) {
      _ini set all $did($dname,16).state
      if ($did($dname,16).state == 1) {
        did -u $dname 5
        did -b $dname 1,5,8,9,10,11
      }
      else {
        did -e $dname 1,5,8,9,10,11
        if ($did($dname,5,1).text) {
          did -c $dname 5 1
          did -r $dname 1
          _cmbload $dname 1 set . $+ $did($dname,5,1)
        }
        did -f $dname 5
      }
    }
    if ($did == 5) && ($did($dname,5).sel isnum) {
      did -r $dname 1
      _cmbload $dname 1 set . $+ $did($dname,5,$did($dname,5).sel)
    }
    if ($did == 10) && (!$did($dname,5).sel) && ($did($dname,5).text) {
      did -a $dname 5 $did($dname,5).text
      did -c $dname 5 $did($dname,5).lines
      _ini set networks $_cmbsave($dname,5)
      did -r $dname 1
      _cmbload $dname 1 set . $+ $did($dname,5).text
      did -f $dname 5
    }
    if ($did == 11) && ($did($dname,5).sel isnum) {
      var %s $did($dname,5).sel
      did -d $dname 5 %s
      _ini set networks $_cmbsave($dname,5)
      did -r $dname 1
      while (%s > 0) {
        if ($did($dname,5,%s).text) {
          did -c $dname 5 %s
          _cmbload $dname 1 set . $+ $did($dname,5,%s)
          break
        }
        dec %s
      }
      did -f $dname 5
    }
    if ($did == 8) && (!$did($dname,1).sel) && ($did($dname,1).text) && ($did($dname,5).seltext) {
      var %t $did($dname,1).text
      did -a $dname 1 $iif($left(%t,1) != $chr(35),$+($chr(35),%t),%t)
      did -c $dname 1 $did($dname,1).lines
      _ini set $+(.,$did($dname,5).seltext) $_cmbsave($dname,1)
      did -f $dname 1
    }
    if ($did == 9) && ($did($dname,1).sel isnum) {
      var %s $did($dname,1).sel
      did -d $dname 1 %s
      _ini set $+(.,$did($dname,5).seltext) $_cmbsave($dname,1)
      while (%s > 0) {
        if ($did($dname,1,%s).text) {
          did -c $dname 1 %s
          break
        }
        dec %s
      }
      did -f $dname 1
    }
  }
  if ($devent == close) {
    if ($did($dname,3).text) { _ini set trigger $iif($gettok($did($dname,3).text, 1, 32),$ifmatch,!imdb) }
  }
}
on *:DIALOG:_imdb.proxy:*:*: {
  if ($devent == init) {
    did -a $dname 3 $_ini(set, host)
    did -a $dname 5 $_ini(set, port)
    if (!$_ini(set, proxy)) || (!$_ini(set, host)) || (!$_ini(set, port)) { did -b $dname 3,5 }
    else { did -c $dname 6 }
  }
  elseif ($devent == sclick) {
    if ($did == 6) {
      _ini set proxy $did($dname,6).state
      if ($did($dname,6).state == 1) { did -e $dname 3,5 }
      else { did -b $dname 3,5 }
    }
  }
  elseif ($devent == close) {
    _ini set host $did($dname,3).text
    _ini set port $did($dname,5).text
  }
}
on *:DIALOG:_imdb.ban:*:*: {
  if ($devent == init) {
    var %i 1
    while (%i <= $_ban(0)) {
      did -a $dname 1 $_ban(%i)
      inc %i
    }
  }
  elseif ($devent == sclick) {
    if ($did == 3) && ($did($dname, 1).text) {
      did -a $dname 1 $did($dname, 1).text
      did -c $dname 1 $did($dname,1).lines
      did -f $dname 1
    }
    if ($did == 4) && ($did($dname, 1).sel) {
      var %s $did($dname, 1).sel
      did -d $dname 1 %s
      while (%s > 0) {
        if ($did($dname,1,%s).text) {
          did -c $dname 1 %s
          break
        }
        dec %s
      }
      did -f $dname 1
    }
    else { did -f $dname 1 }
  }
  elseif ($devent == close) {
    _ini ban
    var %i 1
    while (%i <= $did($dname, 1).lines) {
      _ini ban %i $did($dname, 1, %i)
      inc %i
    }
  }
}
on *:DIALOG:_imdb.output:*:*: {
  if ($devent == init) {
    did -r $dname 1,2,3
    did -a $dname 2 Movie
    did -a $dname 2 Cast
    did -a $dname 2 List
    did -a $dname 2 None
    did -a $dname 2 Miss
    did -a $dname 2 Error
    did -c $dname 2 1
    var %i 1, %n $_mini(outp, 0, movie_*)
    while (%i <= %n) {
      var %s = $_mini(outp, %i, movie_*)
      var %o = $+(%o,$_ini(outp, %s),$iif(%i != %n,$crlf))
      inc %i
    }
    did -a $dname 1 %o
    did -j $dname 1
    did -c $dname 1 1
    did -a $dname 3 $did($dname, 2).text
  }
  if (($devent == sclick) && ($did == 2) && ($did($dname, 1).edited)) || (($devent == close) && ($did($dname, 1).edited)) {
    var %m = $+($lower($did($dname, 3).text),_*)
    var %i 1
    while (%i <= $_mini(outp, 0, %m)) {
      _ini outp $_mini(outp, %i, %m)
      inc %i
    }
    var %i 1
    while (%i <= $did($dname, 1).lines) {
      var %m = $+($lower($did($dname, 3).text),_,%i)
      var %t = $did($dname, 1, %i).text
      if (%t) {
        _ini outp %m $_replace(%t)
        inc %i
      }
      else { did -d $dname 1 %i }
    }
  }
  if ($devent == sclick) {
    if ($did == 2) {
      did -ra $dname 3 $did($dname, 2).text
      did -r $dname 1
      var %i 1, %n $_mini(outp, 0, $+($did($dname,2).seltext,_*))
      while (%i <= %n) {
        var %s = $_mini(outp, %i, $+($did($dname,2).seltext,_*))
        var %o = $+(%o,$_ini(outp, %s),$iif(%i != %n,$crlf))
        inc %i
      }
      did -a $dname 1 %o
      did -j $dname 1
      did -c $dname 1 1
    }
  }
}


this outputs

<@jolly> [IMDb] Spider-Man (2002) ( http://www.imdb.com/title/tt0145487/ )
<@jolly> Genre: Action / Fantasy / Sci-Fi / Thriller
<@jolly> Tagline: With great power comes great responsibility.
<@jolly> Runtime: 121 min
<@jolly> Rating: [**********] 7.4/10 (115,015 votes)

but all i dont really need output at all
i just want to use the information in another script to act upon
and i have another difficulty which needs working out

lets say, my string looks like this Spider.man.2.RECENT-BLAH
or it could looke like Spider.man.2.SOMETHING.ELSE-BLAH

i want to find a way to make a .txt file filled with stuff like
RECENT, SOMETHING etc and if the script reads from that
it will determine which part it usefull to submit to imdb to search
ie it has to cut out everything starting with the word that is in the TXT so it will only keep Spider.Man.2 and it needs to remove the dots so in the end all it searches for is 'Spider Man 2'
after that it should set variables for it to %imdb-rating
and %imdb-votes
so my scripts has the info to work with which i can use with ifnum hopefully

i hope this explained enough for someone better at scripting than me to point me in the right direction

please ask if stuff needs to be cleared up

/bwuser

Last edited by bwuser; 21/11/07 10:10 AM.
bwuser #190573 22/11/07 08:03 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
does anyone know if what im trying to achieve is possible at all?

bwuser #190844 27/11/07 07:12 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Is it always Spider.Man.2(.)

another dot after the movie or a - like Spider.Man.2-something blah

??


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Lpfix5 #190868 28/11/07 02:51 AM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Here's another 1.

Code:
alias imdb {
  unset %imdb.search*
  if ($sock(imdb.search)) { sockclose imdb.search }
  sockopen imdb.search www.imdb.com 80
  sockmark imdb.search $+(/find?q=,$repSpaces($1-))
}
alias -l repSpaces { return $replace($1-,$chr(32),+) }
alias -l _GET {
  var %% = sockwrite -n $sockname , %location = $sock($sockname).mark
  %% GET %location HTTP/1.0
  %% Host: www.imdb.com
  %%
}
alias -l _LOCATION {
  var %x = $regsubex($1-,m@^http://[^/]*@,)
  noop $regex(%x,m@^(/.*?/.*?/)@)
  sockopen imdb.title www.imdb.com 80
  sockmark imdb.title $regml(1)
  sockclose imdb.search
  unset %imdb.search*
}


on *:sockopen:imdb.search:{ _GET }

on *:sockread:imdb.search:{
  var %s | sockread %s
  if (!%imdb.search_body) {
    if (!%s) { set %imdb.search_body 1 }
    if ($regex(%s,/Location: (.*)$/)) { _LOCATION $regml(1) | return }
  }
  elseif ($regex(%s,/<p><b>Popular Titles<\/b> \(Displaying \d+ Results?\)<ol><li>\s+<a href="([^"]*?)"/)) {
    _LOCATION $regml(1) | return
  }
  elseif ($regex(%s,/<b>No Matches.<\/b>/)) { echo -sg There were no matches. | unset %imdb.search* }
}

on *:sockopen:imdb.title:{ _GET }

on *:sockread:imdb.title:{
  var %s | sockread %s
  if ($regex(%s,/<title>(.*?)<\/title>/)) { echo -sg Title: $regml(1) | return }
  elseif ($regex(%s,/<b>User Rating:<\/b>/)) { set -z %imdb.rate 5 | return }
  if (%imdb.rate && $regex(%s,/<b>(.*?)<\/b>/)) { echo -sg Rating: $regml(1) | unset %imdb.rate | return }
}

LostShadow #190881 28/11/07 10:31 AM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
the other . is always there
there is different information after movie title
sometimes year or source or something else
but ALWAYS something but i can make a list of words that come right after the movie hence me looking for a way to make it read from a .txt for things to read before so to speak

i hope this was clear enough

/bwuser

bwuser #190943 29/11/07 01:37 AM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Could you list that to me or pm me with it? all the words you think


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Lpfix5 #190953 29/11/07 01:23 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
Live.Free.or.Die.Hard.UNRATED.DVDRip.XviD-SAPHiRE
P2.DVDSCR.XviD-DiAMOND
Michael.Clayton.PROPER.TS.XviD-PreVail
Lions.For.Lambs.REAL.TELECINE.XViD-PUKKA
Control.LiMiTED.DVDSCR.XViD-HL
Bee.Movie.REPACK.TS.XviD-PreVail

so the words would be : UNRATED,DVDRip,XviD,DVDSCR,PROPER,TS,REAL,TELECINE,LIMITED,REPACK
etc the list gets quite extensive so it would be nice to read from a txt

i appreciate the help

/bwuser

bwuser #191002 30/11/07 01:46 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Ok, how do you want this script to function?

That it always saves anything with those words in it to txt file, then what about after how do you want to "trigger" the search on IMDB?

Do you want an INPUT command or on TEXT command?

Or do you want a dialog script to pick through your current list?


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Lpfix5 #191004 30/11/07 02:09 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
In the mean time Ill show you how to parse the data using Token Identifiers and $regex with $regml for a return match

A) What I want you to do is copy the little list that you got there and save it to test.txt in the main mirc folder

Then execute the script as shown in the below syntax...

Syntax: //echo -a $Rread(nth)
nth is the number line in your text.

Code:
alias Rread {
  noop $regex($read(test.txt,n,$1),/((?i)UNRATED|(?i)DVDRip|(?i)XviD|(?i)DVDSCR|(?i)PROPER|(?i)TS|(?i)REAL|(?i)TELECINE|(?i)LIMITED|(?i)REPACK)/)
  return $replace($deltok($read(test.txt,n,$1),$+($findtok($read(test.txt,n,$1),$regml(1),46),-),46),.,$chr(32))
}


This will return the data without .......-

Steps...

A) I did a regex match in the incoming data for the "words"

B) I first used $findtok with chr being a (.) to find the actual word that the regex match found to use the regex match within the findtok I used $regml(1)

C) During the same string, after I found the token I used deltok to deleted anything FROM(word) to the end leaving anything before.

D) I used the same string to $replace everything in the string's (.) with $chr(32) "space" in succession returning the data prior to the token command with no (.)

----

EDIT: I forgot to add (?i) for non case sensitive matches

Last edited by Lpfix5; 30/11/07 02:15 PM.

Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard