mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
hello all,
ok i found this imdb script and i'm trying to make a personal addy instead of it being a public trigger as was origanlly... i'm trying to work it thru a dialog but i know nothing about sockets and such and i'm bot sure how to convert. heres the mess i have :

Code:
alias movieinfo { sockopen movieinfo1 www.imdb.com 80 | echo -at A } 

on *:sockopen:movieinfo1: { 
  sockwrite -n $sockname GET /find?q= $+ $replace(%movietitle,$chr(32),$(%20,)) $+ s=all HTTP/1.1 
  sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf 
  set %zinfonumber 1 
  ;echo -at Succesfully Opened Socket 
} 
on *:sockread:movieinfo1:{ 
  if ($sockerr) { 
    ;echo -a Error 
    Halt 
  } 
  else { 
    var %tmptxt 
    sockread -f %tmptxt 
    ;echo -a %tmptxt 
    if (Location: isin %tmptxt) { 
      set %movieinfolink2 $remove(%tmptxt,Location: http://www.imdb.com) 
      sockopen movieinfo2 www.imdb.com 80 
    } 
    else { 
      if (<p><b>Popular Titles</b> isin %tmptxt) { 
        set %movieinfolink2 $gettok(%tmptxt,2,34) 
        echo -a %movieinfolink2 
        sockopen movieinfo2 www.imdb.com 80 
      } 
    } 
  } 
} 

on *:sockopen:movieinfo2:{ 
  sockwrite -n $sockname GET %movieinfolink2 HTTP/1.1 
  sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf 
  set %zinfonumber 1 
} 

on *:sockread:movieinfo2:{ 
  if ($sockerr) { 
    ;echo -a Error 
    Halt 
  } 
  else { 
    var %tmptxt 
    sockread -f %tmptxt 
    ;echo -a %tmptxt 
    if (<b class="ch"> isin %tmptxt) { 
      if (%zinfonumber <= 3) { 
        if (%zinfonumber = 1) { inc %zinfonumber } 
        elseif (%zinfonumber = 2) { hadd $remove(%movietitle,$chr(32)) $+ .hsh Tagline $remove($replace($htmlconv(%tmptxt),Tagline:,­Tagline:­,Plot Outline:,­Plot Outline:­ ),(more),(view trailer))
          inc %zinfonumber
        } 
        elseif (%zinfonumber = 3) { hadd $remove(%movietitle,$chr(32)) $+ .hsh Plot $remove($replace($htmlconv(%tmptxt),Tagline:,­Tagline:­,Plot Outline:,­Plot Outline:­ ),(more),(view trailer))
          inc %zinfonumber
          replywithstuff
        } 
        ;echo -at $remove($replace($htmlconv(%tmptxt),Tagline:,­Tagline:­,Plot Outline:,­Plot Outline:­ ),(more),(view trailer)) 
      } 
      if (Genre: isin %tmptxt) { set %genrecatch 1 } 
    } 
    elseif (%genrecatch <= 1) { 
      hadd $remove(%movietitle,$chr(32)) $+ .hsh Genre ­Genre:­ $+ $chr(32) $+ $remove($htmlconv(%tmptxt).rem,(more)) 
      unset %genrecatch 
    } 
  } 
} 


alias htmlconv { 
  var %t, %u = $regsub($replace($1,<br>,$crlf),/^[^<]*>|<[^>]*>|<[^>]*$/g,,%t) 
  if (!$regex(%t,/&\S+?;/)) return %t 
  if ($prop == rem) return $(,,$regsub(%t,/&\S+?;/g,,%t)) %t 
  %t = $replace(%t, ,$chr(160),",",<,<,>,>,&,&,…,...,®,®, $& 
    ©,©,,™,™,¼,¼,½,½,¾,¾,³,³,²,²,°,°,•,•, $& 
    ›,›,‹,‹,»,»,«,’,’,‘,‘,&rdguo;,”,“,“,–, $& 
    –,—,—,',',˜,~,×,×,÷,÷,¶,¶,&ecute;,é,&Ecute;,É,¢, $& 
    ¢,£,£,¥,¥,§,§) 
  if ($version < 6.14) || (!$regex(%t,/&\S+?;/)) return %t 
  var %html = html $+ $ticks, %body = body $+ $ticks 
  .comopen %html htmlfile 
  if ($comerr) return %t 
  %t = $com(%html,write,1,bstr*,$+(<html><body>,%t,</body></html>)) 
  %t = $com(%html,body,2,dispatch* %body) $com(%body,innertext,2) 
  %t = $com(%body).result 
  :error 
  if ($com(%body)) .comclose %body 
  if ($com(%html)) .comclose %html 
  return %t 
} 

alias _htmlconv { 
  if (!$isfile($1)) || ($os isin 9598) return 0 
  var %in = $shortfn($1), %out = $shortfn($2), %mss = mss $+ $ticks 
  if (* !iswm $2) %out = %in 
  .comopen %mss MSScriptControl.ScriptControl 
  if ($comerr) return 0 
  var %t, %n = $crlf 
  %t = $com(%mss,language,4,bstr*,vbscript) 
  %t = $& 
    set html = createobject("htmlfile") %n $& 
    set fso = createobject("scripting.filesystemobject") %n $& 
    set inf = fso.opentextfile( $+(",%in,") ) %n $& 
    src = inf.readall %n $& 
    inf.close %n $& 
    html.write "<html><body>" & src & "</body></html>" %n $& 
    set outf = fso.createtextfile( $+(",%out,") ,true) %n $& 
    outf.write html.body.innertext %n $& 
    outf.close 
  %t = $com(%mss,executestatement,1,bstr*,%t) 
  .comclose %mss 
  return %t 
  :error 
  if ($com(%mss)) .comclose %mss 
  return 0 
} 

alias -l replywithstuff {
  did -a my_imdb 3 $did(my_imdb,2) 
  did -a my_imdb 5 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Genre)
  did -a my_imdb 7 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Tagline)
  did -a my_imdb 1 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Plot)
  hsave -o $mircdirimdb\$remove(%movietitle,$chr(32)) $+ .hsh $remove(%movietitle,$chr(32)) $+ .hsh 

} 
dialog my_imdb {
  title "IMdb Personal Search Results"
  size -1 -1 243 106
  option dbu
  edit "", 2, 54 10 133 10
  edit "", 3, 42 33 82 10
  edit "", 4, 42 43 62 10
  edit "", 5, 131 44 99 10
  edit "", 6, 152 33 35 10
  text "Search For:", 7, 24 12 28 8
  text "Movie Title:", 8, 12 34 28 8
  text "Genre:", 9, 112 45 17 8
  text "Director:", 10, 19 44 21 8
  text "Runtime:", 11, 129 34 22 8
  edit "", 12, 42 52 62 10
  text "Rating:", 13, 22 54 18 8
  edit "", 14, 131 53 99 10
  button "Search!", 16, 200 9 37 12
  text "Tag Line:", 17, 107 55 23 7
  button "Done", 18, 215 22 22 12, ok
  text "Movie Plot:", 15, 92 67 27 8
  edit "", 1, 6 76 231 22, multi
}
on *:dialog:my_imdb:sclick:*: {
  if ($did == 16) {
    if ($isfile(\imdb\$remove($did(2),$chr(32)) $+ .hsh ) == $true) {
      hload $remove($did(2),$chr(32)) $+ .hsh $remove($did(2),$chr(32)) $+ .hsh 
      did -a $dname 3 $did(2) 
      did -a $dname 5 $hget($remove($did(2),$chr(32)) $+ .hsh,Genre)
      did -a $dname 7 $hget($remove($did(2),$chr(32)) $+ .hsh,Tagline)
      did -a $dname 1 $hget($remove($did(2),$chr(32)) $+ .hsh,Plot)
    } 
    else {
      if (isdir(imdb) == true ) {
        hmake $remove($did(2),$chr(32)) $+ .hsh
        sockopen movieinfo1 www.imdb.com 80
        set %movietitle $did(my_imdb,2) 

      } 
      else {
        mkdir imdb
        hmake $remove($did(2),$chr(32)) $+ .hsh
        sockopen movieinfo1 www.imdb.com 80
        set %movietitle $did(my_imdb,2) 
      } 
    }
  } 
}

  


in addition to converting this to work via the dialog for a quieter way to search... i'm also in need of some parsing advice as well ... i want to pull more info from the site but not sure how... the format is a lil bit different for these items the the others .. but first i'd like to get this working with the dialog....

any help will be appreciated .. thanks in advance

Last edited by clutz1572; 19/09/06 05:25 AM.
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
okay this is what i have now.....

Code:
alias movieinfo { sockopen movieinfo1 www.imdb.com 80 | echo -at A } 

on *:sockopen:movieinfo1: { 
  sockwrite -n $sockname GET /find?q= $+ $replace(%movietitle,$chr(32),$(%20,)) $+ s=all HTTP/1.1 
  sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf 
  set %zinfonumber 1 
  ;echo -at Succesfully Opened Socket 
} 
on *:sockread:movieinfo1:{ 
  if ($sockerr) { 
    ;echo -a Error 
    Halt 
  } 
  else { 
    var %tmptxt 
    sockread -f %tmptxt 
    ;echo -a %tmptxt 
    if (Location: isin %tmptxt) { 
      set %movieinfolink2 $remove(%tmptxt,Location: http://www.imdb.com) 
      sockopen movieinfo2 www.imdb.com 80 
      sockclose $sockname
    } 
    else { 
      if (<p><b>Popular Titles</b> isin %tmptxt) { 
        set %movieinfolink2 $gettok(%tmptxt,2,34) 
        echo -a %movieinfolink2 
        sockopen movieinfo2 www.imdb.com 80
        sockclose $sockname 
      } 
    } 
  } 
} 

on *:sockopen:movieinfo2:{ 
  sockwrite -n $sockname GET %movieinfolink2 HTTP/1.1 
  sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf 
  set %zinfonumber 1 
} 

on *:sockread:movieinfo2:{ 
  if ($sockerr) { 
    ;echo -a Error 
    Halt 
  } 
  else { 
    var %tmptxt 
    sockread -f %tmptxt 
    ;echo -a %tmptxt 
    if (<b class="ch"> isin %tmptxt) { 
      if (%zinfonumber <= 7) { 
        if (%zinfonumber = 1) { inc %zinfonumber } 
        elseif (%zinfonumber = 2) {
          hadd $remove(%movietitle,$chr(32)) $+ .hsh Tagline $remove($replace($htmlconv(%tmptxt)),(more),(view trailer))
          inc %zinfonumber
        } 
        elseif (%zinfonumber = 3) { 
          hadd $remove(%movietitle,$chr(32)) $+ .hsh Plot $remove($replace($htmlconv(%tmptxt)),(more),(view trailer))
          inc %zinfonumber

        } 
        elseif  (%zinfonumber = 6) {
          hadd $remove(%movietitle,$chr(32)) $+ .hsh Mpaa $remove($replace($htmlconv(%tmptxt))
          inc %zinfonumber
          replywithstuff
        }
        ;echo -at $remove($replace($htmlconv(%tmptxt),Tagline:,­Tagline:­,Plot Outline:,­Plot Outline:­ ),(more),(view trailer)) 
      } 
      if (Genre: isin %tmptxt) { set %genrecatch 1 } 
    } 
    elseif (%genrecatch <= 1) { 
      hadd $remove(%movietitle,$chr(32)) $+ .hsh Genre ­$remove($htmlconv(%tmptxt).rem,(more)) 
      unset %genrecatch 
    } 
    if (Runtime: isin %tmptxt) { set %runtimecatch  1 }
  }
  elseif (%runtimecatch <= 1) { 
    hadd $remove(%movietitle,$chr(32)) $+ .hsh Runtime $htmlconv(%tmptxt)
    unset %runtimecatch
  } 
  sockclose $sockname
} 


alias htmlconv { 
  var %t, %u = $regsub($replace($1,<br>,$crlf),/^[^<]*>|<[^>]*>|<[^>]*$/g,,%t) 
  if (!$regex(%t,/&\S+?;/)) return %t 
  if ($prop == rem) return $(,,$regsub(%t,/&\S+?;/g,,%t)) %t 
  %t = $replace(%t, ,$chr(160),",",<,<,>,>,&,&,…,...,®,®, $& 
    ©,©,,™,™,¼,¼,½,½,¾,¾,³,³,²,²,°,°,•,•, $& 
    ›,›,‹,‹,»,»,«,’,’,‘,‘,&rdguo;,”,“,“,–, $& 
    –,—,—,',',˜,~,×,×,÷,÷,¶,¶,&ecute;,é,&Ecute;,É,¢, $& 
    ¢,£,£,¥,¥,§,§) 
  if ($version < 6.14) || (!$regex(%t,/&\S+?;/)) return %t 
  var %html = html $+ $ticks, %body = body $+ $ticks 
  .comopen %html htmlfile 
  if ($comerr) return %t 
  %t = $com(%html,write,1,bstr*,$+(<html><body>,%t,</body></html>)) 
  %t = $com(%html,body,2,dispatch* %body) $com(%body,innertext,2) 
  %t = $com(%body).result 
  :error 
  if ($com(%body)) .comclose %body 
  if ($com(%html)) .comclose %html 
  return %t 
} 

alias _htmlconv { 
  if (!$isfile($1)) || ($os isin 9598) return 0 
  var %in = $shortfn($1), %out = $shortfn($2), %mss = mss $+ $ticks 
  if (* !iswm $2) %out = %in 
  .comopen %mss MSScriptControl.ScriptControl 
  if ($comerr) return 0 
  var %t, %n = $crlf 
  %t = $com(%mss,language,4,bstr*,vbscript) 
  %t = $& 
    set html = createobject("htmlfile") %n $& 
    set fso = createobject("scripting.filesystemobject") %n $& 
    set inf = fso.opentextfile( $+(",%in,") ) %n $& 
    src = inf.readall %n $& 
    inf.close %n $& 
    html.write "<html><body>" & src & "</body></html>" %n $& 
    set outf = fso.createtextfile( $+(",%out,") ,true) %n $& 
    outf.write html.body.innertext %n $& 
    outf.close 
  %t = $com(%mss,executestatement,1,bstr*,%t) 
  .comclose %mss 
  return %t 
  :error 
  if ($com(%mss)) .comclose %mss 
  return 0 
} 

alias -l replywithstuff {
  did -a my_imdb 3 $did(my_imdb,2) 
  did -a my_imdb 5 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Genre)
  did -a my_imdb 14 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Tagline)
  did -a my_imdb 1 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Plot)
  did -a my_imdb 12 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Mpaa)
  did -a my_imdb 6 $hget($remove($did(my_imdb,2),$chr(32)) $+ .hsh,Runtime)
  hsave -o $remove(%movietitle,$chr(32)) $+ .hsh $remove(%movietitle,$chr(32)) $+ .hsh 

} 
dialog my_imdb {
  title "IMdb Personal Search Results"
  size -1 -1 243 106
  option dbu
  edit "", 2, 54 10 133 10
  edit "", 3, 42 33 82 10
  edit "", 4, 42 43 62 10
  edit "", 5, 131 44 99 10
  edit "", 6, 152 33 35 10
  text "Search For:", 7, 24 12 28 8
  text "Movie Title:", 8, 12 34 28 8
  text "Genre:", 9, 112 45 17 8
  text "Director:", 10, 19 44 21 8
  text "Runtime:", 11, 129 34 22 8
  edit "", 12, 42 52 62 10
  text "Rating:", 13, 22 54 18 8
  edit "", 14, 131 53 99 10
  button "Search!", 16, 200 9 37 12
  text "Tag Line:", 17, 107 55 23 7
  button "Done", 18, 215 22 22 12, ok
  text "Movie Plot:", 15, 92 67 27 8
  edit "", 1, 6 76 231 22, multi
}
on *:dialog:my_imdb:sclick:*: {
  if ($did == 16) {
    if ($isfile(\imdb\$remove($did(2),$chr(32)) $+ .hsh ) == $true) {
      hload $remove($did(2),$chr(32)) $+ .hsh $remove($did(2),$chr(32)) $+ .hsh 
      did -a my_imdb 3 $did(2) 
      did -a my_imdb 5 $hget($remove($did(2),$chr(32)) $+ .hsh,Genre)
      did -a my_imdb 14 $hget($remove($did(2),$chr(32)) $+ .hsh,Tagline)
      did -a my_imdb 1 $hget($remove($did(2),$chr(32)) $+ .hsh,Plot)
      did -a my_imdb 12 $hget($remove($did(2),$chr(32)) $+ .hsh,Mpaa)
      did -a my_imdb 6 $hget($remove($did(2),$chr(32)) $+ .hsh,Runtime)
    } 
    else {
      if (isdir(imdb) == true ) {
        hmake $remove($did(2),$chr(32)) $+ .hsh
        sockopen movieinfo1 www.imdb.com 80
        set %movietitle $did(my_imdb,2) 
        sockclose movieinfo1
      } 
      else {
        mkdir imdb
        hmake $remove($did(2),$chr(32)) $+ .hsh
        sockopen movieinfo1 www.imdb.com 80
        set %movietitle $did(my_imdb,2) 
        sockclose movieinfo1
      } 
    }
  } 
}

  


now i'm having problems with figuring out where to place the sockclose command... and also i need a way to free up the hash file after the search is complete.. any help will be appreciated..
thanks in advance

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Btw, _htmlconv is only to interpret an entire html file at once, you don't actually need to include it with your code if you're not going to use it, as it is not linked to the htmlconv alias.


Gone.
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
i realized this after my post and have since omitted it... but thanks FiberOPtics smile


Link Copied to Clipboard