Advertisement
mruno

!topdvds

Oct 3rd, 2013
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.35 KB | None | 0 0
  1. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. ;script !rentals Script
  3. ;version Oct2013
  4. ;author mruno
  5. ;email mruno@ircN.org
  6. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. ;
  8. ;
  9. on 1:TEXT:*:#:{
  10.   if (!rentals isin $1) || (!toprentals isin $1) || (!topdvds isin $1)  || (!dvds isin $1) {
  11.     set %get.rentals.TEMP.chan $chan
  12.     set %get.rentals.TEMP.nick $nick
  13.     set %get.rentals.TEMP.info $1
  14.     if (%get.rentals.ON) || ($hget(get.rentals)) .notice %get.rentals.TEMP.nick Please try again in 1 minute.
  15.     else get.rentals
  16.   }
  17. }
  18. alias get.rentals {
  19.   .notice %get.rentals.TEMP.nick %get.rentals.TEMP.info by mruno gathering data, please wait...
  20.   if ($sock(get.rentals)) sockclose get.rentals
  21.   set -u45 %get.rentals.ON 1
  22.   hmake get.rentals
  23.   set %get.rentals.TEMP.num 1
  24.   sockopen get.rentals www.imdb.com 80
  25.   .timerget.rentals.Timeout 1 45 get.rentals.Timeout
  26. }
  27.  
  28. on *:sockopen:Get.Rentals: {
  29.   sockwrite -nt $sockname GET /boxoffice/rentals HTTP/1.1
  30.   sockwrite -nt $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  31.   sockwrite -nt $sockname Host: www.imdb.com
  32.   sockwrite -nt $sockname Accept-Language: en-us
  33.   sockwrite -nt $sockname Accept: */*
  34.   sockwrite -nt $sockname $crlf
  35. }
  36. on *:sockread:Get.Rentals: {
  37.   var %temp, %date, %item, %data
  38.   if ($sockerr) {
  39.     var %error
  40.     if ($sockerr == 3) set %error Connection refused by remote host
  41.     elseif ($sockerr == 4) set %error DNS lookup for hostname failed
  42.     elseif ($sockerr > 0) set %error Unknown socket error ( $+ $sockerr $+ )
  43.     echo -s get.rentals:     4Socket Error: %error
  44.     .timerget.rentals.error 1 10 get.rentals.msg       Socket Error. Please try again later. :(
  45.     timerget.rentals.close 1 15 get.rentals.close
  46.     halt
  47.   }
  48.   else {
  49.     .timerget.rentals.Timeout off
  50.     sockread %temp
  51.     if (Top United States DVD Rentals isin %temp) get.rentals.msg   12 $striphtml(%temp) $+ :
  52.     else {
  53.       if (*<a href="/title/tt*/">*</b></td>* iswm %temp) {
  54.         var %blah  $+ %get.rentals.TEMP.num $+ $chr(41)  $+ $striphtml(%temp)
  55.  
  56.         set %get.rentals.TEMP.data $addtok(%blah,%get.rentals.TEMP.data,187)
  57.         if ($gettok(%get.rentals.TEMP.data,0,187) > 1) {
  58.           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)
  59.           ;$replace(%get.rentals.TEMP.data,$chr(187), $str(.,$calc(50 - $len(%blah))))
  60.           set %get.rentals.TEMP.data
  61.         }
  62.         inc %get.rentals.TEMP.num
  63.       }
  64.     }
  65.     .timerGet.rentals.Close 1 10 Get.rentals.Close
  66.   }
  67. }
  68. alias Get.rentals.Close {
  69.   sockclose Get.rentals
  70.   unset %Get.rentals.TEMP.*
  71.   .timerhfree.get.rentals 1 30 if ($hget(get.rentals)) hfree Get.rentals
  72. }
  73. alias Get.rentals.Timeout {
  74.   get.rentals.msg     Error: The request timed out. Please try again later. :(
  75.   Get.rentals.Close
  76. }
  77. alias get.rentals.msg if (%Get.rentals.TEMP.chan) msg %Get.rentals.TEMP.chan $1-
  78.  
  79. ;==================================================================================
  80. ;Author  : fubar
  81. ;Function: $striphtml identifier
  82. ;          This identifier strips html code from a string of text.
  83. ;         Good for using when retrieving webpages within mirc.  
  84. ;==================================================================================
  85. ;
  86. ;This identifier strips html code from a string of text. Good for using when retrieving webpages within mirc.
  87. ;
  88. ;Usage: $striphtml(html code)
  89. alias -l striphtml {
  90.   ; making sure there are parameters to work with
  91.   IF ($1) {
  92.     ; Setting my variables. The %opt is set kind of funky
  93.     ; all it does is combine <two><brackets> into 1 <twobrackets>, fewer loops this way
  94.     ; also stripped tab spaces
  95.     VAR %strip,%opt = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
  96.     ; using $gettok() I checked the text in front of '>' (chr 62)
  97.     ; then the second $gettok checks the text behind '<' (chr 60)
  98.     ; so I'm extracting anything between >text<
  99.     WHILE ($gettok($gettok(%opt,%n,62),1,60)) {
  100.       ; take each peice of text and add it to the same variable
  101.       %strip = %strip $ifmatch
  102.       %strip = $replace(%strip,&quot;,")
  103.       ; increase the variable so the while statement can check the next part
  104.       INC %n
  105.     }
  106.     ; now that the loop has finished we can return the stripped html code
  107.     RETURN $remove(%strip,&nbsp;,/td,#x26;)
  108.   }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement