Advertisement
mruno

!newdvds

Dec 30th, 2013
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 5.63 KB | None | 0 0
  1. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. ;script !newdvds Script
  3. ;version Nov2013
  4. ;author mruno
  5. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. ;
  7. ;
  8. on 1:TEXT:*:#:{
  9.   if (!rentals isin $1) || (!newrentals isin $1) || (!newdvds isin $1)  || (!dvds isin $1) {
  10.     if (!rentals isin $1) || (!dvds isin $1) && (!$2) { .notice $nick Do you want the NEW dvd releases or TOP releases? Type $1 new or $1 top | return }
  11.     set %get.newdvds.TEMP.chan $chan
  12.     set %get.newdvds.TEMP.nick $nick
  13.     set %get.newdvds.TEMP.info $1
  14.     if ($2 == new) || (!newrentals isin $1) || (!newdvds isin $1) {
  15.       if (!rentals isin $1) || (!dvds isin $1) && (!$2) { .notice $nick Do you want the NEW dvd releases or TOP releases? Type $1 new or $1 top | return }
  16.       else {
  17.         if (%get.newdvds.ON) { .notice %get.newdvds.TEMP.nick Please try again in 1 minute. :) | return }
  18.         else get.newdvds
  19.       }
  20.     }
  21.   }
  22. }
  23. alias get.newdvds {
  24.   .notice %get.newdvds.TEMP.nick %get.newdvds.TEMP.info by mruno gathering data, please wait...
  25.   if ($sock(get.newdvds)) sockclose get.newdvds
  26.   set -u45 %get.newdvds.ON 1
  27.   set %get.newdvds.TEMP.num 1
  28.   sockopen get.newdvds www.imdb.com 80
  29.   .timerget.newdvds.Timeout 1 45 get.newdvds.Timeout
  30. }
  31.  
  32. on *:sockopen:get.newdvds: {
  33.   sockwrite -nt $sockname GET /sections/dvd/
  34.   sockwrite -nt $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  35.   sockwrite -nt $sockname Host: www.imdb.com
  36.   sockwrite -nt $sockname Accept-Language: en-us
  37.   sockwrite -nt $sockname Accept: */*
  38.   sockwrite -nt $sockname $crlf
  39. }
  40. on *:sockread:get.newdvds: {
  41.   var %temp, %date, %item, %data
  42.   if ($sockerr) {
  43.     var %error
  44.     if ($sockerr == 3) set %error Connection refused by remote host
  45.     elseif ($sockerr == 4) set %error DNS lookup for hostname failed
  46.     elseif ($sockerr > 0) set %error Unknown socket error ( $+ $sockerr $+ )
  47.     echo -s get.newdvds:     4Socket Error: %error
  48.     .timerget.newdvds.error 1 10 get.newdvds.msg       Socket Error. Please try again later. :(
  49.     timerget.newdvds.close 1 15 get.newdvds.close
  50.     halt
  51.   }
  52.   else {
  53.     .timerget.newdvds.Timeout off
  54.     sockread %temp
  55.     if (New to Own: isin %temp) {
  56.       get.newdvds.msg   12 $+ $striphtml(%temp)
  57.       set %get.newdvds.TEMP.num 1
  58.     }
  59.     if (href="/title/ isin %temp) && ("item_description" !isin %temp) && (/vote? !isin %temp) && ($striphtml(%temp)) set %get.newdvds.TEMP.title $striphtml(%temp)
  60.     if (<span class="year_type"> isin %temp) && ($striphtml(%temp)) && (%get.newdvds.TEMP.title) {
  61.  
  62.       if ($isodd(%get.newdvds.TEMP.num)) {
  63.         set %get.newdvds.TEMP.echo  $+ %get.newdvds.TEMP.num $+ $chr(41) $+  %get.newdvds.TEMP.title $striphtml(%temp)  $+ $str(.,$calc(50 - $len(%get.newdvds.TEMP.num %get.newdvds.TEMP.title $striphtml(%temp)))) $+ 
  64.         set %get.newdvds.TEMP.last %get.newdvds.TEMP.title
  65.       }
  66.       else {
  67.         set %get.newdvds.TEMP.echo %get.newdvds.TEMP.echo  $+ %get.newdvds.TEMP.num $+ $chr(41)  $+ %get.newdvds.TEMP.title $striphtml(%temp)
  68.         get.newdvds.msg     %get.newdvds.TEMP.echo
  69.         unset %get.newdvds.TEMP.last
  70.       }
  71.       unset %get.newdvds.TEMP.title
  72.       inc %get.newdvds.TEMP.num
  73.     }
  74.     if (See more lists isin %temp) && (%get.newdvds.TEMP.last) get.newdvds.msg      $+ $calc(%get.newdvds.TEMP.num - 1) $+ $chr(41)  $+ %get.newdvds.TEMP.last
  75.     .timerget.newdvds.Close 1 10 get.newdvds.Close
  76.   }
  77. }
  78. alias get.newdvds.Close {
  79.   sockclose get.newdvds
  80.   unset %get.newdvds.TEMP.*
  81. }
  82. alias get.newdvds.Timeout {
  83.   get.newdvds.msg     Error: The request timed out. Please try again later. :(
  84.   get.newdvds.Close
  85. }
  86. alias get.newdvds.msg if (%get.newdvds.TEMP.chan) msg %get.newdvds.TEMP.chan $1-
  87.  
  88. alias -l iseven return $iif(2 // $1,$true,$false)
  89. alias -l isodd return $iif(!$iseven($1),$true,$false)
  90. ;==================================================================================
  91. ;Author  : fubar
  92. ;Function: $striphtml identifier
  93. ;          This identifier strips html code from a string of text.
  94. ;         Good for using when retrieving webpages within mirc.  
  95. ;==================================================================================
  96. ;
  97. ;This identifier strips html code from a string of text. Good for using when retrieving webpages within mirc.
  98. ;
  99. ;Usage: $striphtml(html code)
  100. alias -l Xchr {
  101.   var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2});/g,$chr(\1))
  102.   return $replacecs(%return,&ndash;,–,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,$&
  103.     É,&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,&Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),$&
  104.     &aelig;,æ,&quot;,")
  105. }
  106. alias -l striphtml {
  107.   ; making sure there are parameters to work with
  108.   IF ($1) {
  109.     ; Setting my variables. The %opt is set kind of funky
  110.     ; all it does is combine <two><brackets> into 1 <twobrackets>, fewer loops this way
  111.     ; also stripped tab spaces
  112.     VAR %strip,%opt = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
  113.     ; using $gettok() I checked the text in front of '>' (chr 62)
  114.     ; then the second $gettok checks the text behind '<' (chr 60)
  115.     ; so I'm extracting anything between >text<
  116.     WHILE ($gettok($gettok(%opt,%n,62),1,60)) {
  117.       ; take each peice of text and add it to the same variable
  118.       %strip = %strip $ifmatch
  119.       %strip = $replace(%strip,&quot;,")
  120.       ; increase the variable so the while statement can check the next part
  121.       INC %n
  122.     }
  123.     ; now that the loop has finished we can return the stripped html code
  124.     RETURN $xchr(%strip)
  125.   }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement