Advertisement
mruno

!newdvds

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