Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- ;script !rentals Script
- ;version Oct2013
- ;author mruno
- ;email mruno@ircN.org
- ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- ;
- ;
- on 1:TEXT:*:#:{
- if (!rentals isin $1) || (!toprentals isin $1) || (!topdvds isin $1) || (!dvds isin $1) {
- set %get.rentals.TEMP.chan $chan
- set %get.rentals.TEMP.nick $nick
- set %get.rentals.TEMP.info $1
- if (%get.rentals.ON) || ($hget(get.rentals)) .notice %get.rentals.TEMP.nick Please try again in 1 minute.
- else get.rentals
- }
- }
- alias get.rentals {
- .notice %get.rentals.TEMP.nick %get.rentals.TEMP.info by mruno gathering data, please wait...
- if ($sock(get.rentals)) sockclose get.rentals
- set -u45 %get.rentals.ON 1
- hmake get.rentals
- set %get.rentals.TEMP.num 1
- sockopen get.rentals www.imdb.com 80
- .timerget.rentals.Timeout 1 45 get.rentals.Timeout
- }
- on *:sockopen:Get.Rentals: {
- sockwrite -nt $sockname GET /boxoffice/rentals HTTP/1.1
- sockwrite -nt $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
- sockwrite -nt $sockname Host: www.imdb.com
- sockwrite -nt $sockname Accept-Language: en-us
- sockwrite -nt $sockname Accept: */*
- sockwrite -nt $sockname $crlf
- }
- on *:sockread:Get.Rentals: {
- var %temp, %date, %item, %data
- if ($sockerr) {
- var %error
- if ($sockerr == 3) set %error Connection refused by remote host
- elseif ($sockerr == 4) set %error DNS lookup for hostname failed
- elseif ($sockerr > 0) set %error Unknown socket error ( $+ $sockerr $+ )
- echo -s get.rentals: 4Socket Error: %error
- .timerget.rentals.error 1 10 get.rentals.msg Socket Error. Please try again later. :(
- timerget.rentals.close 1 15 get.rentals.close
- halt
- }
- else {
- .timerget.rentals.Timeout off
- sockread %temp
- if (Top United States DVD Rentals isin %temp) get.rentals.msg 12 $striphtml(%temp) $+ :
- else {
- if (*<a href="/title/tt*/">*</b></td>* iswm %temp) {
- var %blah $+ %get.rentals.TEMP.num $+ $chr(41) $+ $striphtml(%temp)
- set %get.rentals.TEMP.data $addtok(%blah,%get.rentals.TEMP.data,187)
- if ($gettok(%get.rentals.TEMP.data,0,187) > 1) {
- get.rentals.msg $gettok(%get.rentals.TEMP.data,2,187) $str(.,$calc(50 - $len($gettok(%get.rentals.TEMP.data,2,187)))) $gettok(%get.rentals.TEMP.data,1,187)
- ;$replace(%get.rentals.TEMP.data,$chr(187), $str(.,$calc(50 - $len(%blah))))
- set %get.rentals.TEMP.data
- }
- inc %get.rentals.TEMP.num
- }
- }
- .timerGet.rentals.Close 1 10 Get.rentals.Close
- }
- }
- alias Get.rentals.Close {
- sockclose Get.rentals
- unset %Get.rentals.TEMP.*
- .timerhfree.get.rentals 1 30 if ($hget(get.rentals)) hfree Get.rentals
- }
- alias Get.rentals.Timeout {
- get.rentals.msg Error: The request timed out. Please try again later. :(
- Get.rentals.Close
- }
- alias get.rentals.msg if (%Get.rentals.TEMP.chan) msg %Get.rentals.TEMP.chan $1-
- ;==================================================================================
- ;Author : fubar
- ;Function: $striphtml identifier
- ; This identifier strips html code from a string of text.
- ; Good for using when retrieving webpages within mirc.
- ;==================================================================================
- ;
- ;This identifier strips html code from a string of text. Good for using when retrieving webpages within mirc.
- ;
- ;Usage: $striphtml(html code)
- alias -l striphtml {
- ; making sure there are parameters to work with
- IF ($1) {
- ; Setting my variables. The %opt is set kind of funky
- ; all it does is combine <two><brackets> into 1 <twobrackets>, fewer loops this way
- ; also stripped tab spaces
- VAR %strip,%opt = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
- ; using $gettok() I checked the text in front of '>' (chr 62)
- ; then the second $gettok checks the text behind '<' (chr 60)
- ; so I'm extracting anything between >text<
- WHILE ($gettok($gettok(%opt,%n,62),1,60)) {
- ; take each peice of text and add it to the same variable
- %strip = %strip $ifmatch
- %strip = $replace(%strip,",")
- ; increase the variable so the while statement can check the next part
- INC %n
- }
- ; now that the loop has finished we can return the stripped html code
- RETURN $remove(%strip, ,/td,#x26;)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement