One of my friends coded a similar socket script but in a different coding language (he says it's not MSL and I don't know what it is), so I've decided to take his "layout" and transform it into a usable mIRC-version script.
This was one of my more difficult socket scripts, as I had to sockopen twice into the same website. One of the many problems was redirection of pages. On the first sockopen, it went to the search page as expected, but in other cases, it directly linked to the movie/tv show page.
I am surprised though, at how fast the script works (approximately > 4 ~ 5 seconds to message results), despite the two sockopens.
Anyhow I've fixed all known errors, but of course, if you find any errors please post a comment on this snippet page. :)
[size=16]Syntax: .imdb <movie/tv show>.[/size]
[size=14]I've also added a menu function to turn the script on or off, and yes, there is a 15-second flood protection[/size]
If you don't have a bot, you can use this version: http://www.impulze.net/paste/11597/
If you love expanded form and is a absolute vitality to your existence:
http://www.impulze.net/paste/11599/
Thank you to Blitzjager for lending me a hand with one of the identifiers.
I hope you enjoy the [size=14]stars[/size].
[size=25]Enjoy! :D[/size]
;BOF
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
; IMDB Movie/TV Show Searcher ;
; Made by Kirby (Quakenet) ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;~*~*~*~*~*~*~*~*~*~*~*~*;
;IMDB Aliases/Identifiers;
;~*~*~*~*~*~*~*~*~*~*~*~*;
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }
alias -l between { noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) | return $regml($4) }
alias -l char { return $replace($regsubex($1,/&#(x?([a-f\d]*));/gi,$chr($iif($left(\1,1) == x,$base(\2,16,10),\2))),&,&,<,<,>,>,",") }
alias -l div { var %x $calc($0 - 1), %y 1 | while (%y < %x) { if ($ [ $+ [ %y ] ] != $null) { var %z %z $ [ $+ [ %y ] ] $chr($iif($ [ $+ [ $0 ] ] !isnum 1-,$chr(45),$v1)) } | inc %y } | var %z %z $ [ $+ [ $calc($0 - 1) ] ] | return $deltok(%z,$calc($numtok(%z,45)+1),45) }
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | return $remove($replace(%x,$cr,$chr(32),$lf,$chr(32)),$chr(9)) }
alias -l lt { var %l $1, %t $2- | tokenize 94 $sock(imdb2).mark | while ($len(%t) > %l) { smsg $1 $left(%t,%l) | var %t $remove(%t,$left(%t,%l)) } | if (%t) smsg $1 %t }
alias -l smsg { msg $iif(c isincs $chan($1).mode,$1 $strip($2-),$1-) }
alias -l star { var %x $iif($abs($round($1,0)) <= 10,$v1,10) | return $+($str(8*,%x),$str(*,$calc(10-%x))) }
menu * {
$iif($group(#IMDB) == On,$style(1)) IMDB Movie/TV Show Search
.$iif($group(#IMDB) == On,$style(2)) On: .enable #IMDB
.$iif($group(#IMDB) == Off,$style(2)) Off: .disable #IMDB
}
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;Search a movie/tv show - Syntax: .imdb [movie/tv show];
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
#IMDB On
on $*:text:/^[.!@]imdb*/Si:#: { if (!$2-) { .notice $nick [1,8Internet Movie Database]: You must supply a movie/tv show to search! | halt } | $iif($istok(%internetmoviedatabase,#,32),halt,set -u1 %internetmoviedatabase $addtok(%internetmoviedatabase,#,32)) | sockopen imdb www.imdb.com 80 | sockmark imdb # $replace($2-,$chr(32),+) }
#IMDB End
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;Socket #1 (Finds first "exact match" link);
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
on *:sockopen:imdb: { tokenize 32 $sock(imdb).mark | sockwrite -n $sockname GET /find?s=all&q= $+ $2 HTTP/1.0 | sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf }
on *:sockread:imdb: {
tokenize 32 $sock(imdb).mark | sockread %imdb
if (<p style="margin:0 0 0.5em 0;"> isin %imdb) { if ($gettok($gettok(%imdb,4,34),1,47) != title) { halt } | elseif ($gettok($gettok(%imdb,4,34),1,47) == title) { sockmark imdb $+($1,^,$gettok(%imdb,4,34)) | halt } }
elseif (Location: isin %imdb) { sockmark imdb $+($1,^,$gettok($gettok(%imdb,2,32),3,109)) | halt }
elseif (<b>Titles (Exact Matches)</b> isin %imdb) { sockmark imdb $+($1,^,$noqt($between($between(%imdb,<b>Titles $+($chr(40),Exact Matches,$chr(41),</b>),$+(=",$chr(40),new Image,$chr(40),$chr(41),$chr(41),.src='),1),<a href=,onclick,1))) | halt }
}
on *:sockclose:imdb: { sockopen imdb2 www.imdb.com 80 | sockmark imdb2 $gettok($sock(imdb).mark,1-2,94) }
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;Socket #2 (Retrieves information from page);
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
on *:sockopen:imdb2: { tokenize 94 $sock(imdb2).mark | sockwrite -n $sockname GET $2 HTTP/1.0 | sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf }
on *:sockread:imdb2: {
sockread %imdb2 | tokenize 94 $sock(imdb2).mark
if (<title> isin %imdb2) {
if ($htmlfree(%imdb2) == 400 Bad Request) || ($htmlfree(%imdb2) == IMDb:Permission denied) { sockclose imdb2 | msg $gettok($1,1,32) [1,8Internet Movie Database]: Error: Could not retrieve $replace($iif($gettok($1,2,32) == $null,your word,$+(',$v1,')),+,$chr(32)) from the database. Search another movie/tv show? - (15 seconds until next IMDB search) | halt }
sockmark imdb2 $addmark(imdb2,Title: $+(,$char($htmlfree(%imdb2)),),94)
}
elseif (<div class="meta"> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Rating: $star($gettok($htmlfree(%imdb2),1,47)) $+($chr(40),,$iif($replace($htmlfree(%imdb2),$chr(40),$null,$chr(41),$null),$v1,None),,$chr(41)),94) }
elseif (<h5>MOVIEmeter: isin %imdb2) { sockmark imdb2 $addmark(imdb2,MOVIEmeter: $+(,$iif($gettok($gettok($htmlfree(%imdb2),1,46),2-7,32),$v1,None),),94) }
elseif (<h5>Release Date:</h5> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Release Date: $+(,$iif(%imdb2,$v1,None),),94) }
elseif (<h5>Genre:</h5> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Genre: $+(,$remove($replace($htmlfree(%imdb2),|,$chr(183)),$+($chr(32),more)),),94) }
elseif (<h5>Tagline:</h5> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Tagline: $+($remove($htmlfree(%imdb2),$+($chr(32),more))),94) | halt }
elseif (<h5>Awards:</h5> isin %imdb2) { var %x <a class="tn15more inline" | while (%x !isin %imdb2) { var %imdb3 $addtok(%imdb3,$htmlfree(%imdb2),32) | sockread %imdb2 } | sockmark imdb2 $addmark(imdb2,Awards: $+(,$iif($mid(%imdb3,9,$len(%imdb3)),$v1,None),),94) }
}
on *:sockclose:imdb2: { tokenize 94 $sock(imdb2).mark | lt 440 $remove($gettok($1,1,32),$1) [1,8Internet Movie Database]: $iif($numtok($sock(imdb2).mark,94) >= 1,$div($iif($3,$v1,$null),$iif($4,$v1,$null),$iif($5,$v1,$null),$iif($6,$v1,$null),$iif($7,$v1,$null),$iif($8,$v1,$null),$iif($9,$v1,$null),45),Error: Couldn't find your movie/tv show. Search another?) | lt 425 $remove($gettok($1,1,32),$1) [1,8Internet Movie Database]: URL: $+(,http://,$sock(imdb2).addr,$2,) - (15 seconds until next IMDB search) | unset %imdb* }
;EOF
After a few more rounds of testing, I seem to have resolved the issue with my edit above:> !imdb avatar
[Internet Movie Database]: Title: Avatar (2009) - MOVIEmeter: Up 12% in popularity this week - Release Date: 18 December 2009 (USA) - Genre: - Tagline: - Awards: Won 3 Oscars. Another 28 wins & 53 nominations lt 425 [Internet Movie Database]: URL: http://www.imdb.com/title/tt0499549/ - (15 seconds until next IMDB search) !imdb chainsaw [Internet Movie Database]: Title: The Texas Chainsaw Massacre (2003) - MOVIEmeter: No change in popularity this week - Release Date: 17 October 2003 (USA) - Genre: - Tagline: - Awards: 4 wins & 10 nominations lt 425 [Internet Movie Database]: URL: http://www.imdb.com/title/tt0324216/ - (15 seconds until next IMDB search) !imdb there's something about mary [Internet Movie Database]: Title: There's Something About Mary (1998) - MOVIEmeter: Up 19% in popularity this week - Release Date: 15 July 1998 (USA) - Genre: - Tagline: - Awards: Nominated for 2 Golden Globes. Another 16 wins & 11 nominations lt 425 [Internet Movie Database]: URL: http://www.imdb.com/title/tt0129387/ - (15 seconds until next IMDB search) !imdb shrek [Internet Movie Database]: Title: Shrek (2001) - MOVIEmeter: Up 4% in popularity this week - Release Date: 18 May 2001 (USA) - Genre: - Tagline: - Awards: Won Oscar. Another 29 wins & 44 nominations lt 425 [Internet Movie Database]: URL: http://www.imdb.com/title/tt0126029/ - (15 seconds until next IMDB search) !imdb Lion kings [Internet Movie Database]: Title: The Lion King (1994) - MOVIEmeter: No change in popularity this week - Release Date: 24 June 1994 (USA) - Genre: - Tagline: - Awards: Won 2 Oscars. Another 22 wins & 22 nominations lt 425 [Internet Movie Database]: URL: http://www.imdb.com/title/tt0110357/ - (15 seconds until next IMDB search)I also removed and cleaned some bits here and there to make it more uniform. Kiby's way of scripting is putting everything together in a very long line, which makes his script harder to read. Enjoy the fix, folks.Here is my attempt to fix the issue, and it should work correctly now:
menu * {
$iif($group(#IMDB) == On,$style(1)) IMDB Movie/TV Show Search
.$iif($group(#IMDB) == On,$style(2)) On: .enable #IMDB
.$iif($group(#IMDB) == Off,$style(2)) Off: .disable #IMDB
}
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }
alias -l between { noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) | return $regml($4) }
alias -l char { return $replace($regsubex($1,/&#(x?([a-f\d]*));/gi,$chr($iif($left(\1,1) == x,$base(\2,16,10),\2))),&,&,<,<,>,>,",") }
alias -l div { var %x $calc($0 - 1), %y 1 | while (%y < %x) { if ($ [ $+ [ %y ] ] != $null) { var %z %z $ [ $+ [ %y ] ] $chr($iif($ [ $+ [ $0 ] ] !isnum 1-,$chr(45),$v1)) } | inc %y } | var %z %z $ [ $+ [ $calc($0 - 1) ] ] | return $deltok(%z,$calc($numtok(%z,45)+1),45) }
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | return $remove($replace(%x,$cr,$chr(32),$lf,$chr(32)),$chr(9)) }
alias -l lt { var %l $1, %t $2- | tokenize 94 $sock(imdb2).mark | while ($len(%t) > %l) { smsg $1 $left(%t,%l) | var %t $remove(%t,$left(%t,%l)) } | if (%t) smsg $1 %t }
alias -l smsg { msg $iif(c isincs $chan($1).mode,$1 $strip($2-),$1-) }
alias -l star { var %x $iif($abs($round($1,0)) <= 10,$v1,10) | return $+($str(8*,%x),$str(*,$calc(10-%x))) }
#IMDB On
on $*:text:/^[.!@]imdb*/Si:#: { if (!$2-) { .notice $nick [1,8Internet Movie Database]: You must supply a movie/tv show to search! | halt } | $iif($istok(%internetmoviedatabase,#,32),halt,$&
set -u1 %internetmoviedatabase $addtok(%internetmoviedatabase,#,32)) | sockopen imdb www.imdb.com 80 | sockmark imdb # $replace($2-,$chr(32),+) }
#IMDB End
on *:sockopen:imdb: { tokenize 32 $sock(imdb).mark | sockwrite -n $sockname GET /find?s=all&q= $+ $2 HTTP/1.0 | sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf }
on *:sockread:imdb: {
tokenize 32 $sock(imdb).mark | sockread %imdb
if (<p style="margin:0 0 0.5em 0;"> isin %imdb) { if ($gettok($gettok(%imdb,4,34),1,47) != title) { halt } | elseif ($gettok($gettok(%imdb,4,34),1,47) == title) { sockmark imdb $+($1,^,$gettok(%imdb,4,34)) | halt } }
elseif (Location: isin %imdb) { sockmark imdb $+($1,^,$gettok($gettok(%imdb,2,32),3,109)) | halt }
elseif (<b>Titles (Exact Matches)</b> isin %imdb) { sockmark imdb $+($1,^,$noqt($between($between(%imdb,<b>Titles $+($chr(40),Exact Matches,$chr(41),</b>),$+(=",$chr(40),new Image,$chr(40),$chr(41),$chr(41),.src='),1),<a href=,onclick,1))) | halt }
}
on *:sockclose:imdb: { sockopen imdb2 www.imdb.com 80 | sockmark imdb2 $gettok($sock(imdb).mark,1-2,94) }
on *:sockopen:imdb2: { tokenize 94 $sock(imdb2).mark | sockwrite -n $sockname GET $2 HTTP/1.0 | sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf }
on *:sockread:imdb2: {
var %imdb2 | sockread %imdb2
if (<title> isin %imdb2) {
if ($htmlfree(%imdb2) == 400 Bad Request) || ($htmlfree(%imdb2) == IMDb:Permission denied) { sockclose imdb2 | notice $nick ERROR: Could not retrieve $replace($iif($gettok($1,2,32) == $null,$&
your word,$+(',$v1,')),+,$chr(32)) from the database. Search another movie/tv show? - (15 seconds until next IMDB search)
}
sockmark imdb2 $addmark(imdb2,Title: $+(,$char($htmlfree(%imdb2)),),94)
}
elseif (<div class="meta"> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Rating: $star($gettok($htmlfree(%imdb2),1,47)) $+($chr(40),,$iif($replace($htmlfree(%imdb2),$chr(40),$null,$chr(41),$null),$v1,None),,$chr(41)),94) }
elseif (<h5>MOVIEmeter: isin %imdb2) { sockmark imdb2 $addmark(imdb2,MOVIEmeter: $+(,$iif($gettok($gettok($htmlfree(%imdb2),1,46),2-7,32),$v1,None),),94) }
elseif ($regex(%imdb2,/(\d{2} \S+ \d{4} \(\S+\))/)) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Release Date: $+(,$iif(%imdb2,$regml(1),None),),94) }
elseif (<h5>Genre:</h5> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Genre: $+(,$remove($replace($htmlfree(%imdb2),|,$chr(183)),$+($chr(32),more)),),94) }
elseif (<h5>Tagline:</h5> isin %imdb2) { sockread %imdb2 | sockmark imdb2 $addmark(imdb2,Tagline: $+($remove($htmlfree(%imdb2),$+($chr(32),more))),94) | halt }
elseif (<h5>Awards:</h5> isin %imdb2) { var %x <a class="tn15more inline" | while (%x !isin %imdb2) { var %imdb3 $addtok(%imdb3,$htmlfree(%imdb2),32) | sockread %imdb2 } | sockmark imdb2 $addmark(imdb2,Awards: $+(,$iif($mid(%imdb3,9,$len(%imdb3)),$replace($v1,&,&),None),),94) }
}
on *:sockclose:imdb2: { tokenize 94 $sock(imdb2).mark | lt 440 $remove($gettok($1,1,32),$1) [1,8Internet Movie Database]: $iif($numtok($sock(imdb2).mark,94) >= 1,$div($iif($3,$v1,$null),$iif($4,$v1,$null),$iif($5,$v1,$null),$iif($6,$v1,$null),$iif($7,$v1,$null),$iif($8,$v1,$null),$&
$iif($9,$v1,$null),45),Error: Couldn't find your movie/tv show. Search another?) $remove($gettok($1,1,32),$1) [1,8Internet Movie Database]: URL: $+(,http://,$sock(imdb2).addr,$2,) - (15 seconds until next IMDB search) | unset %imdb*
}
(11:36:50) (VinX) !imdb New Moon
(11:37:29) (~v2-BoT) [Internet Movie Database]: Title: New Moon (2009) - MOVIEmeter: Up 17% in popularity this week - Release Date:
Release Date : !?!
Great contribution Kirby, been using this script for a couple months now on my bot, I like the look better than the previous script I was using. However, someone just noticed in one of my chans that it is not grabbing the Genre when it posts to the channel. We tried several queries, and none of them come back with a Genre result. I don't know socket scripting, so I can't really figure out a way to fix it myself, unfortunately. Just wanted to call it to your attention in case you're monitoring this post. Thanks.
hey Kirby , really great script... how ever the http://www.impulze.net/paste links are not working . getting a timeout trying to reach em. posible you could upload it to pastebin or something?
is it posible you could get it to spam box office aswell ? would be nice to have that imo.
great work thou :)
Kirby, it is not a case of not understanding the script or needing you to elaborate on any parts. I'm merely stating a point that obviously others have an issue with too. Was I flaming? No, what are comments for? For leaving constructive feedback, likes/dislikes, additions etc of the script? Yes.
I was looking for a good imdb script to use as I didn't much feel like coding one myself, laziness, lack of time, whatever the reason.
As I said, the script is great & works very well. I understand how it works but don't like the colours, the way it delivers to the channel etc. Rarely when I use someone else's script do I not edit it to suit the way I like things & I'm sure I am not the only one. I was simply stating for that reason alone I would not use it. Call it constructive criticism or flaming as you wish, but if you are supplying scripts in the hope that other people will use them, maybe you would like to know what others think for future reference in the hope that more people will use it.
In future I will simply not comment on any of your snippets in an effort to avoid offending your fragile ego further.
Kirby, buddy pal, it's a decent script, and works so thats good, its not THAT useful its just a extra type script imo, nothing one truly need, it's fun, but no 10. Dunno why ppl are having fit over the WAY its coded, tbh it's irrelevant, just use it or don't?. B tw wtf happened to hawkee.com, this whole place has become katty as hell =\, sorta sad.
Regardless of the fact that it's a bit difficult to read, I don't see why you would not use the script.
Of course if the script doesn't interest you, you wouldn't bother to look at it; but the coding style?> would start on the next line instead of using " | " but I guess it's down to personal preferenceLike you said, it's a personal preference, but I don't see why you would want to not use it.
I can assume that the reason why you don't want to use it is because it is difficult to edit/debug; you have no idea what is happening in the script, what parts can be edited, etc. Well, there's nothing I can really do about it to make you understand; I code in a rather different way; even understanding the code may be difficult for most. I don't guarantee that the user will understand the code, because that's, ultimately, their 'job'. It's their duty, if they were to edit/debug, to understand what is going on in the script, and hold responsibility of what they've done. For example, someone edited parts of the script but had almost no idea of what he or she was doing. They would then blame it on the script maker for having the script "too hard to read" or "too bunched up". That is completely irrelevant to the script. Which leads to what I have to say next.
If you were to ask me to elaborate on the script, I would be more than happy to do so, but having interest in the script, but not even using it because it's not your coding style? Or similarly, "I don't know what's going on, so I'm going to flame the poster, why didn't you make it easier for 'us' to read?" Ridiculous, in my opinion. Like you said: "personal preference".
I do not appreciate whining and complaining about the script's structure - if the result of the code is buggy, then obviously that's something that I will take into consideration; but how I digress many times, what you are saying is completely irrelevant.
Eugenio, I will not use a script unless I can read and understand every single line of it. Doing otherwise would be ignorant on my part.I don't have to explain what every single line is in the script, because that is virtually impossible.
But don't get me wrong - what you're saying is absolutely true. It may be harder to read/debug. I just take a different approach than you do.
However, I appreciate your comments, but if you want an expanded version so much, here you go. But I am NOT changing what I have posted.
Script is great and works very well, but I'm with FordLawnmower on the code layout. There is never any need for such long lines of code, that's what the Enter key is for.
I would start on the next line instead of using " | " but I guess it's down to personal preference. I think it makes it a lot easier on the eye if you wish to edit or look at the script & removes the need to scroll in the editor.
For this reason I would not use this script, I could edit it to make it how I like it, or I could just use another or write one.