Advertisement
mruno

!topdvds

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