|
Joined: Aug 2004
Posts: 423
Fjord artisan
|
OP
Fjord artisan
Joined: Aug 2004
Posts: 423 |
sorry for the second post, i've been searching the forums for help with this.. and i found some good stuff, but i'm still having problems.. first off now i'm flooding myself off and not sure why, second i'm in need of some help with parsing html code that on two lines... and i think i may have the sockclose commands in order... but could use some advise on that.. now for testing purposes i kept this code to the orig order. here's the code:
on *:TEXT:!movieinfo *:#ghettowtest:{
if ($isfile($remove($2-,$chr(32)) $+ .hsh ) == $true) {
hload $remove($2-,$chr(32)) $+ .hsh $remove($2-,$chr(32)) $+ .hsh
msg $nick MovieInfo For $2-
msg $nick $hget($remove($2-,$chr(32)) $+ .hsh,Genre)
msg $nick $hget($remove($2-,$chr(32)) $+ .hsh,Tagline)
msg $nick $hget($remove($2-,$chr(32)) $+ .hsh,Plot)
msg $nick $hget($remove($2-,$chr(32)) $+ .hsh,Runtime)
msg $nick $hget($remove($2-,$chr(32)) $+ .hsh,site)
}
else {
hmake $remove($2-,$chr(32)) $+ .hsh
set %movietitle $2-
set %movieinfonick $nick
msg $nick Please Wait While We Retrieve The Info (No longer Then 30 Secs)
movieinfo
}
}
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)
sockclose movieinfo1
sockopen movieinfo2 www.imdb.com 80
}
else {
if (<p><b>Popular Titles</b> isin %tmptxt) {
set %movieinfolink2 $gettok(%tmptxt,2,34)
echo -a %movieinfolink2
sockclose movieinfo1
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
hadd $remove(%movietitle,$chr(32)) $+ .hsh site For Full Details Visit: http://www.imdb.com $+ %movieinfolink2
}
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 }
;echo -at $remove($replace($htmlconv(%tmptxt),Tagline:,Tagline:,Plot Outline:,Plot Outline: ),(more),(view trailer))
}
if (Genre: isin %tmptxt) { set %genrecatch 1 }
if (Runtime: isin %tmptxt) { set %runtimecatch 6 }
}
elseif (%genrecatch <= 1) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Genre Genre: $+ $chr(32) $+ $remove($htmlconv(%tmptxt).rem,(more))
unset %genrecatch
}
elseif (%runtimecatch <= 6) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Runtime Runtime: $+ $chr(32) $+ $htmlconv(%tmptxt).rem
unset %%runtimecatch
replywithstuff
}
}
}
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,&nbsp;,$chr(160),&quot;,",&lt;,<,&gt;,>,&amp;,&,&hellip;,...,&reg;,®, $&
&copy;,©,,&trade;,™,&frac14;,¼,&frac12;,½,&frac34;,¾,&sup3;,³,&sup2;,²,&deg;,°,&bull;,•, $&
&rsaquo;,›,&lsaquo;,‹,&raquo;,»,&laquo;,&rsquo;,’,&lsquo;,‘,&rdguo;,”,&ldquo;,“,&ndash;, $&
–,&mdash;,—,&apos;,',&tilde;,~,&times;,×,&divide;,÷,&para;,¶,&ecute;,é,&Ecute;,É,&cent;, $&
¢,&pound;,£,&yen;,¥,&sect;,§)
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 -l replywithstuff {
msg %movieinfonick MovieInfo For %movietitle
msg %movieinfonick $hget($remove(%movietitle,$chr(32)) $+ .hsh,Genre)
msg %movieinfonick $hget($remove(%movietitle,$chr(32)) $+ .hsh,Tagline)
msg %movieinfonick $hget($remove(%movietitle,$chr(32)) $+ .hsh,Plot)
msg %movieinfonick $hget($remove(%movietitle,$chr(32)) $+ .hsh,Runtime)
hsave -o $remove(%movietitle,$chr(32)) $+ .hsh $remove(%movietitle,$chr(32)) $+ .hsh
msg %movieinfonick For Full Details Visit: http://www.imdb.com $+ %movieinfolink2
hfree $remove(%movietitle,$chr(32)) $+ .hsh
}
this is the error msg i get when flooding off: /msg: insufficient parameters (line 114, script3.mrc) which is this line: msg %movieinfonick $hget($remove(%movietitle,$chr(32)) $+ .hsh,Genre) so any advice would be appreciated on this and of course suggestions are alsways welcomed thanks in advance
|
|
|
|
Joined: Aug 2004
Posts: 423
Fjord artisan
|
OP
Fjord artisan
Joined: Aug 2004
Posts: 423 |
ok well i figured out the flooding part and have got the sockclose issues hashed out.... but i have a couple of new questions... here's what i have now :
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="blackcatheader"> isin %tmptxt) {
if (Directed isin %tmptxt) { set %directcatch 1 }
}
elseif (%directcatch <= 1) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Director $htmlconv(%tmptxt).rem
unset %directcatch
}
if (<b class="ch"> isin %tmptxt) {
if (%zinfonumber <= 8) {
if (%zinfonumber = 1) { inc %zinfonumber }
elseif (%zinfonumber = 2) { hadd $remove(%movietitle,$chr(32)) $+ .hsh Tagline $remove($htmlconv(%tmptxt),Tagline:,(more),(view trailer))
inc %zinfonumber
}
elseif (%zinfonumber = 3) { hadd $remove(%movietitle,$chr(32)) $+ .hsh Plot $remove($htmlconv(%tmptxt),Plot $+ $chr(32) $+ 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 $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,&nbsp;,$chr(160),&quot;,",&lt;,<,&gt;,>,&amp;,&,&hellip;,...,&reg;,®, $&
&copy;,©,,&trade;,™,&frac14;,¼,&frac12;,½,&frac34;,¾,&sup3;,³,&sup2;,²,&deg;,°,&bull;,•, $&
&rsaquo;,›,&lsaquo;,‹,&raquo;,»,&laquo;,&rsquo;,’,&lsquo;,‘,&rdguo;,”,&ldquo;,“,&ndash;, $&
–,&mdash;,—,&apos;,',&tilde;,~,&times;,×,&divide;,÷,&para;,¶,&ecute;,é,&Ecute;,É,&cent;, $&
¢,&pound;,£,&yen;,¥,&sect;,§)
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 -l replywithstuff {
did -ra my_imdb 3 %movietitle
did -ra my_imdb 4 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Director)
did -ra my_imdb 5 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Genre)
did -ra my_imdb 14 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Tagline)
did -ra my_imdb 1 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Plot)
hsave $remove(%movietitle,$chr(32)) $+ .hsh $remove(%movietitle,$chr(32)) $+ .hsh
sockclose movieinfo1 | sockclose movieinfo2
hfree $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) {
set %movietitle $did(2)
did -r $dname 2
if $isfile($remove(%movietitle,$chr(32)) $+ .hsh) {
hmake $remove(%movietitle,$chr(32)) $+ .hsh
hload $remove(%movietitle,$chr(32)) $+ .hsh $remove(%movietitle,$chr(32)) $+ .hsh
did -ra $dname 3 %movietitle
did -ra $dname 4 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Director)
did -ra $dname 5 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Genre)
did -ra $dname 7 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Tagline)
did -ra $dname 1 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Plot)
}
else {
hmake $remove(%movietitle,$chr(32)) $+ .hsh
movieinfo
}
}
}
this code works very well... except when it pulls the director info, i get two blocks at the end?? don't know why . another thing is that the hash file that gets saved for some reason gets titled $remove(%movietitle,$chr(32)).hsh ??? and this kinda halts the script. i also want to get some other info from my searches... like movie runtimes and also MPAA rattings if available... thos pieces look like this: <b class="ch">Runtime:</b> USA:98 min <br> and <b class="ch"><a href="/mpaa">MPAA</a>:</b> Rated PG for crude humor, innuendo and language.<br> but the mpaa rating isn't available on all searches.. and for the runtime results i only want the 98 min portion since many search results wont have country classification.. any help on these issues will be appreciated greatly... as well as comments on how i can improve this code.. thanks in advance... (again)
|
|
|
|
|