Advertisement
anon

tvrage

Nov 10th, 2012
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 14.50 KB | None | 0 0
  1. ; ===============================
  2. ; TVRage Script v1 by ES and hxck
  3. ; ===============================
  4.  
  5. on *:LOAD: {
  6.   /echo -s TVRage v1 :: $chr(91) ES & hxck $chr(93) has been loaded. Type !tvhelp for a list of commands. http://www.hawkee.com/snippet/8822/
  7. }
  8.  
  9. on *:TEXT:!tvhelp:#: {
  10.  
  11.   msg # !n|!next - Get next episode information (ie !n Dexter)
  12.   msg # !l|!last - Get last episode information (ie !l Dexter)
  13.   msg # !tv - Get general show information (ie !tv Dexter)
  14.   msg # !ep seasonXepisode show - Get episode summary (ie !ep 1x2 Dexter)
  15.   msg # !show - Get show summary (ie !show Dexter)
  16.  
  17. }
  18.  
  19. menu Channel,Status {
  20.   .$iif($group(#TVR) == On,$style(1)) ES/hxck
  21.   ..$iif($group(#TVR) == On,$style(2)) TVRage On: .enable #TVR
  22.   ..$iif($group(#TVR) == Off,$style(2)) TVRage Off: .disable #TVR
  23. }
  24. #TVR on
  25. on *:TEXT:!*:#: {
  26.  
  27.   ; ===========================
  28.   ; Close sockets if we need to
  29.   ; ===========================
  30.  
  31.   if ($sock(tvrage)) { sockclose tvrage }
  32.   if ($sock(tvrage2)) { sockclose tvrage2 }
  33.   if ($sock(tvrage3)) { sockclose tvrage3 }
  34.  
  35.   ; ===========================
  36.   ; Set different triggers here
  37.   ; ===========================
  38.  
  39.   if (($1 == !n) || ($1 == !next)) {
  40.     if (!$2) { msg # Syntax: !n <show name> }
  41.     if ($2) {
  42.       set %tvr.output next
  43.       set %tvr.show $replace($2-,$chr(32),$chr(37) $+ 20)
  44.       sockopen -n tvrage services.tvrage.com 80
  45.       sockmark tvrage msg #
  46.     }
  47.   }
  48.   if (($1 == !l) || ($1 == !last)) {
  49.     if (!$2) { msg # Syntax: !l <show name> }
  50.     if ($2) {
  51.       set %tvr.output last
  52.       set %tvr.show $replace($2-,$chr(32),$chr(37) $+ 20)
  53.       sockopen -n tvrage services.tvrage.com 80
  54.       sockmark tvrage msg #
  55.     }
  56.   }
  57.   if ($1 == !tv) {
  58.     if (!$2) { msg # Syntax: !tv <show name> }
  59.     if ($2) {
  60.       set %tvr.output info
  61.       set %tvr.show $replace($2-,$chr(32),$chr(37) $+ 20)
  62.       sockopen -n tvrage services.tvrage.com 80
  63.       sockmark tvrage msg #
  64.     }
  65.   }
  66.   if ($1 == !ep) {
  67.     if (!$2) { msg # Syntax: !ep <ep number, eg 1x1> <show name> | halt }
  68.     if (!$3) { msg # Syntax: !ep <ep number, eg 1x1> <show name> | halt }
  69.     else {
  70.       set %tvr.output.nick $nick
  71.       set %tvr.output epsummary
  72.       set %tvr.show $replace($3-,$chr(32),$chr(37) $+ 20)
  73.       set %tvr.epnum $2
  74.       sockopen -n tvrage services.tvrage.com 80
  75.     }
  76.   }
  77.   if ($1 == !show) {
  78.     if (!$2) { msg # Syntax: !show <show name> }
  79.     else {
  80.       set %tvr.output.nick $nick
  81.       set %tvr.show $replace($2-,$chr(32),$chr(37) $+ 20)
  82.       set %tvr.output showsummary
  83.       sockopen -n tvrage services.tvrage.com 80
  84.       sockmark tvrage msg #
  85.     }
  86.   }
  87.   else halt
  88. }
  89.  
  90. ; ===========================
  91. ; Handle sockopen events here
  92. ; ===========================
  93.  
  94. on *:SOCKOPEN:tvrage: {
  95.   var %s sockwrite -n $sockname
  96.   if ($sockerr) { $sock(tvrage).mark Socket Error: $sock(tvrage).wsmsg }
  97.   %s GET /tools/quickinfo.php?show= $+ %tvr.show $+ &ep= $+ %tvr.epnum HTTP/1.1
  98.   %s Host: services.tvrage.com
  99.   %s Connection: close
  100.   %s $crlf
  101. }
  102.  
  103. on *:SOCKOPEN:tvrage2: {
  104.   var %s sockwrite -n $sockname
  105.   if ($sockerr) { $sock(tvrage2).mark Socket Error: $sock(tvrage2).wsmsg }
  106.   %s GET %tvr.epsumurl HTTP/1.1
  107.   %s Host: www.tvrage.com
  108.   %s Connection: close
  109.   %s $crlf
  110. }
  111.  
  112. on *:SOCKOPEN:tvrage3: {
  113.   var %s sockwrite -n $sockname
  114.   if ($sockerr) { $sock(tvrage3).mark Socket Error: $sock(tvrage3).wsmsg }
  115.   %s GET /myfeeds/showinfo.php?key=sqsTSaJG4qJagM6ldpKZ&sid= $+ %tvr.showid HTTP/1.1
  116.   %s Host: services.tvrage.com
  117.   %s Connection: close
  118.   %s $crlf
  119. }
  120.  
  121. ; ===========================
  122. ; Handle sockread events here
  123. ; ===========================
  124.  
  125. on *:SOCKREAD:tvrage: {
  126.   if ($sockerr) { $sock(tvrage).mark Socket Error: $sock(tvrage).wsmsg }
  127.   var %tvrtemp
  128.   sockread %tvrtemp
  129.  
  130.   ; ============================
  131.   ; Set !n !l !tv variables here
  132.   ; ============================
  133.   if ((%tvr.output == next) || (%tvr.output == last) || (%tvr.output == info)) {
  134.     if (Show Name isin %tvrtemp) { set %tvr.showname $gettok(%tvrtemp,2,64) }
  135.     if (Show URL isin %tvrtemp) { set %tvr.url $gettok(%tvrtemp,2,64) }
  136.     if (Premiered isin %tvrtemp) { set %tvr.premiered $gettok(%tvrtemp,2,64) }
  137.     if (Started isin %tvrtemp) { set %tvr.started $gettok(%tvrtemp,2,64) }
  138.     if (Ended isin %tvrtemp) { set %tvr.ended $gettok(%tvrtemp,2,64) }
  139.     if (Country isin %tvrtemp) { set %tvr.country $gettok(%tvrtemp,2,64) }
  140.     if (Status isin %tvrtemp) { set %tvr.status $gettok(%tvrtemp,2,64) }
  141.     if (Classification isin %tvrtemp) { set %tvr.class $gettok(%tvrtemp,2,64) }
  142.     if (Genres isin %tvrtemp) { set %tvr.genres $gettok(%tvrtemp,2,64) }
  143.     if (Network isin %tvrtemp) { set %tvr.network $gettok(%tvrtemp,2,64) }
  144.     if (Airtime isin %tvrtemp) { set %tvr.airtime $gettok(%tvrtemp,2,64) }
  145.     if (Runtime isin %tvrtemp) { set %tvr.runtime $gettok(%tvrtemp,2,64) }
  146.     if (Next Episode isin %tvrtemp) {
  147.       set %tvr.nextemp $gettok(%tvrtemp,2,64)
  148.       set %tvr.nextepnum $gettok(%tvr.nextemp,1,94)
  149.       set %tvr.nextepname $gettok(%tvr.nextemp,2,94)
  150.       set %tvr.nextepday $gettok(%tvr.nextemp,3,94)
  151.     }
  152.     if (Latest Episode isin %tvrtemp) {
  153.       set %tvr.lastemp $gettok(%tvrtemp,2,64)
  154.       set %tvr.lastepnum $gettok(%tvr.lastemp,1,94)
  155.       set %tvr.lastepname $gettok(%tvr.lastemp,2,94)
  156.       set %tvr.lastepday $gettok(%tvr.lastemp,3,94)
  157.     }
  158.     if (GMT+0 NODST isin %tvrtemp) { set %tvr.airnextepcmt $calc($gettok(%tvrtemp,2,64) - 36004 - $gmt) }
  159.     if (%tvr.country == Australia) {
  160.       set %tvr.airnextepcmt $calc($gettok(%tvrtemp,2,64) - 28800 - $gmt)
  161.     }
  162.  
  163.  
  164.   }
  165.   ; ==============================
  166.   ; Set 1st !tvinfo variables here
  167.   ; ==============================
  168.  
  169.   if (%tvr.output == showsummary) {
  170.     if (Show ID isin %tvrtemp) { set %tvr.showid $gettok(%tvrtemp,2,64) }
  171.     if (Show Name isin %tvrtemp) { set %tvr.showname $gettok(%tvrtemp,2,64) }
  172.     if (Show URL isin %tvrtemp) { set %tvr.url $gettok(%tvrtemp,2,64) }
  173.   }
  174.  
  175.   ; ==========================
  176.   ; Set 1st !ep variables here
  177.   ; ==========================
  178.  
  179.   if (%tvr.output == epsummary) {
  180.     if (Episode URL isin %tvrtemp) {
  181.       set %tvr.url $gettok(%tvrtemp,2,64)
  182.       set %tvr.epsumurl $remove($gettok(%tvrtemp,2,64),http://www.tvrage.com)
  183.     }
  184.     if (Episode info isin %tvrtemp) {
  185.       set %tvr.epnumout $gettok($gettok(%tvrtemp,2,64),1,94)
  186.       set %tvr.epname $gettok($gettok(%tvrtemp,2,64),2,94)
  187.       set %tvr.epair $gettok($gettok(%tvrtemp,2,64),3,94)
  188.     }
  189.     if (Show Name isin %tvrtemp) { set %tvr.showname $gettok(%tvrtemp,2,64) }
  190.   }
  191. }
  192.  
  193. on *:SOCKREAD:tvrage2: {
  194.   if ($sockerr) { $sock(tvrage).mark Socket Error: $sock(tvrage2).wsmsg }
  195.  
  196.   ; ==========================
  197.   ; Set 2nd !ep variables here
  198.   ; ==========================
  199.  
  200.   var %tvrtemp2
  201.   sockread %tvrtemp2
  202.   if (%tvr.epsum.temp == 1) {
  203.     set %tvr.epsum %tvrtemp2
  204.     set %tvr.epsum.temp 0
  205.   }
  206.   if (<div class='show_synopsis'> isin %tvrtemp2) { set %tvr.epsum.temp 1 }
  207. }
  208.  
  209. on *:SOCKREAD:tvrage3: {
  210.   if ($sockerr) { $sock(tvrage).mark Socket Error: $sock(tvrage3).wsmsg }
  211.  
  212.   ; ==============================
  213.   ; Set 2nd !tvinfo variables here
  214.   ; ==============================
  215.  
  216.   var %tvrtemp3
  217.   sockread %tvrtemp3
  218.   if (<image> isin %tvrtemp3) { set %tvr.showpic $between(%tvrtemp3,<image>,</image>,1) }
  219.   if (<summary> isin %tvrtemp3) { set %tvr.showsummary $between(%tvrtemp3,<summary>,</summary>,1) }
  220.  
  221. }
  222.  
  223. ; ============================
  224. ; Handle sockclose events here
  225. ; ============================
  226.  
  227. on *:SOCKCLOSE:tvrage: {
  228.  
  229.   ; ============================
  230.   ; Next Episode
  231.   ; ============================
  232.  
  233.   if (%tvr.output == next) {
  234.     if ((%tvr.nextemp != $null) && (%tvr.nextepday == TBA)) {
  235.       $sock(tvrage).mark $chr(91) 07 $+ %tvr.showname $+  $chr(93) :: $chr(91) 6 $+ Airs %tvr.airtime on %tvr.network $+  $chr(93) :: $chr(91) $+ 7 %tvr.nextepnum  $+ $chr(93) :: $chr(91) 7 $+ %tvr.nextepname $+  $chr(93) :: $chr(91) 7 $+ %tvr.nextepday $+  $chr(93)
  236.       unset %tvr.* | halt
  237.     }
  238.     if (%tvr.nextemp != $null) && (Season isin %tvr.nextepname) && (%tvr.nextepday == TBA) {
  239.       $sock(tvrage).mark  $chr(91) 07 $+ %tvr.showname $+  $chr(93) :: $chr(91) 6 $+ Airs %tvr.airtime on %tvr.network $+  $chr(93) :: $chr(91) $+ 7 %tvr.nextepnum  $+ $chr(93) :: $chr(91) 7 $+ %tvr.nextepname $+  $chr(93) :: $chr(91) 7 $+ %tvr.nextepday $+  $chr(93)
  240.       unset %tvr.* | halt
  241.     }
  242.     if (%tvr.nextemp != $null) && (Season isin %tvr.nextepname) && (/ isin %tvr.nextepday) {
  243.       $sock(tvrage).mark  $chr(91) 07 $+ %tvr.showname $+  $chr(93) :: $chr(91) 6 $+ Airs %tvr.airtime on %tvr.network $+  $chr(93) :: $chr(91) $+ 7 %tvr.nextepnum  $+ $chr(93) :: $chr(91) 7 $+ %tvr.nextepname $+  $chr(93) $iif($left(%tvr.airnextepcmt,1) != -,:: $chr(91) 7 $+ %tvr.nextepday $+  $chr(93) :: $chr(91) 6 $+ Airing in: $betterduration(%tvr.airnextepcmt) $+  $chr(93),:: $chr(91) 7 $+ %tvr.nextepday $+  $chr(93) 6 $+ Aired: $betterduration(%tvr.airnextepcmt) ago. )
  244.  
  245.       unset %tvr.* | halt
  246.     }
  247.     if (%tvr.nextemp != $null) {
  248.       $sock(tvrage).mark  $chr(91) 07 $+ %tvr.showname $+  $chr(93) :: $chr(91) 6 $+ Airs %tvr.airtime on %tvr.network $+  $chr(93) :: $chr(91) $+ 7 %tvr.nextepnum  $+ $chr(93) :: $chr(91) 7 $+ %tvr.nextepname $+  $chr(93) $iif($left(%tvr.airnextepcmt,1) != -,:: $chr(91) 7 $+ %tvr.nextepday $+  $chr(93) :: $chr(91) 6 $+ Airing in: $betterduration(%tvr.airnextepcmt) $+  $chr(93),:: $chr(91) 7 $+ %tvr.nextepday $+  $chr(93) 6 $+ Aired: $betterduration(%tvr.airnextepcmt) ago. )
  249.       unset %tvr.* | halt
  250.     }
  251.     if (%tvr.nextemp == $null) {
  252.       $sock(tvrage).mark Next episode information for %tvr.showname is unavailable.
  253.       unset %tvr.* | halt
  254.     }
  255.   }
  256.  
  257.   ; ============================
  258.   ; Last Episode
  259.   ; ============================
  260.  
  261.   if (%tvr.output == last) {
  262.     if (%tvr.lastemp != $null) {
  263.       $sock(tvrage).mark $chr(91) 07 $+ %tvr.showname $+  $chr(93) :: $chr(91) $iif(%tvr.ended != $null,06 $+ Aired,06 $+ Airs) %tvr.airtime on %tvr.network $+  $chr(93) :: $chr(91) 07 $+ %tvr.lastepnum  $chr(93) :: $chr(91) 07 $+ %tvr.lastepname $+  $chr(93) :: $chr(91) 06 $+ %tvr.lastepday $+  $chr(93) :: $chr(91) 07 $+ https://broadcasthe.net/torrents.php?searchstr= $+ $replace(%tvr.showname,$chr(32),$chr(43)) $+ $chr(43) $+ s $+ $replace(%tvr.lastepnum,x,e) $+  $chr(93)
  264.       unset %tvr.* | halt
  265.     }
  266.     if (%tvr.nextemp == $null) {
  267.       $sock(tvrage).mark Last episode information for 07 $+ $replace(%tvr.show,$chr(37) $+  20,$chr(32)) is unavailable.
  268.       unset %tvr.* | halt
  269.     }
  270.   }
  271.  
  272.   ; ============================
  273.   ; Show Information
  274.   ; ============================
  275.  
  276.   if (%tvr.output == info) {
  277.     ; msg %tvr.output.chan
  278.     if (%tvr.showname != $null) {
  279.       $sock(tvrage).mark $chr(91) 07 $+ %tvr.showname $+  $chr(93) :: 06 $+ %tvr.url $+
  280.       if (%tvr.ended != $null) {
  281.         $sock(tvrage).mark 07 $+ Premiered: $+  06 $+ %tvr.started - 07 $+ Ended: $+  %tvr.ended $+
  282.       }
  283.       else {
  284.         $sock(tvrage).mark 07 $+ Premiered: $+  6 $+ %tvr.started $+  - 6 $+ %tvr.status 7 $+ ( $+ %tvr.country $+ ) $+
  285.       }
  286.       $sock(tvrage).mark 7 $+ Airs $+  6 $+ %tvr.airtime $+  7 $+ on $+  6 $+ %tvr.network $+  7 $+ ( $+ %tvr.runtime min $+ ) $+ 
  287.       $sock(tvrage).mark 6 $+ %tvr.genres $+ 
  288.       $sock(tvrage).mark 7 $+ Classification: $+  6 $+ %tvr.class $+ 
  289.       unset %tvr.* | halt
  290.     }
  291.     if (%tvr.showname == $null) {
  292.       $sock(tvrage).mark Show does not exist. Please check your spelling and try again.
  293.       unset %tvr.* | halt
  294.     }
  295.   }
  296.  
  297.   ; ============================
  298.   ; Ep Information
  299.   ; ============================
  300.  
  301.   if (%tvr.output == epsummary) {
  302.     sockopen -n tvrage2 www.tvrage.com 80
  303.   }
  304.  
  305.   ; ============================
  306.   ; TVinfo Information
  307.   ; ============================
  308.  
  309.   if (%tvr.output == showsummary) {
  310.     sockopen -n tvrage3 services.tvrage.com 80
  311.   }
  312. }
  313.  
  314. on *:SOCKCLOSE:tvrage2: {
  315.  
  316.   ; ============================
  317.   ; Ep Information
  318.   ; ============================
  319.  
  320.   if (Click Here To Add isin %tvr.epsum) { notice %tvr.output.nick Sorry, no summary availible for episode %tvr.epnumout of %tvr.showname }
  321.   else {
  322.     notice %tvr.output.nick $chr(91) 7 $+ %tvr.showname $+  $chr(93) $chr(91) $+ 7 %tvr.epnumout - %tvr.epname  $+ $chr(93) $chr(91) $+ 7 %tvr.epair  $+ $chr(93) 6 $+ %tvr.url $+ 
  323.     notice %tvr.output.nick $nohtml(%tvr.epsum)
  324.  
  325.     ;unset %tvr.* | halt
  326.   }
  327. }
  328.  
  329. on *:SOCKCLOSE:tvrage3: {
  330.  
  331.   ; ============================
  332.   ; Show Summary
  333.   ; ============================
  334.  
  335.   query %tvr.output.nick $chr(91) 7 $+ %tvr.showname $chr(93)  6 $+ %tvr.url $+ 
  336.   query %tvr.output.nick $replace(%tvr.showsummary,&quot;,")
  337.  
  338.   query %tvr.output.nick $chr(91) 7 $+ Show image $+  $chr(93) %tvr.showpic
  339.  
  340.   /close -m %tvr.output.nick
  341.   unset %tvr.* | halt
  342.  
  343. }
  344.  
  345.  
  346. ; ===========================
  347. ; Aliases
  348. ; ===========================
  349.  
  350. alias -l nohtml {
  351.   var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  352.   return %x
  353. }
  354. alias between { noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) | return $regml($4) }
  355.  
  356. ; ==============================================
  357. ; Thanks to http://www.nealirc.org/IRC/mIRC.html
  358. ; ==============================================
  359.  
  360. alias betterduration {
  361.   var %lifeseconds = $abs($1)
  362.   var %age, %years, %months, %days, %hours, %minutes, %seconds, %temp
  363.   %years = $int($calc(%lifeseconds / 31557600))
  364.   if (%years != 0) %age = %years year $+ $iif(%years > 1,s) $+ ,
  365.   %temp = $calc(%lifeseconds - (%years * 31557600))
  366.   %months = $int($calc(%temp / 2678400))
  367.   if (%months != 0) %age = %age %months month $+ $iif(%months > 1,s) $+ ,
  368.   %temp = $calc(%temp - (%months * 2678400))
  369.   %weeks = $int($calc(%temp / 604800))
  370.   if (%weeks != 0) %age = %age %weeks week $+ $iif(%weeks > 1,s) $+ ,
  371.   %temp = $calc(%temp - (%weeks * 604800))
  372.   %days = $int($calc(%temp / 86400))
  373.   if (%days != 0) %age = %age %days day $+ $iif(%days > 1,s) $+ ,
  374.   %temp = $calc(%temp - (%days * 86400))
  375.   %hours = $int($calc(%temp / 3600))
  376.   if (%hours != 0) %age = %age %hours hour $+ $iif(%hours > 1,s) $+ ,
  377.   %temp = $calc(%temp - (%hours * 3600))
  378.   %minutes = $int($calc(%temp / 60))
  379.   if (%minutes != 0) %age = %age %minutes minute $+ $iif(%minutes > 1,s)
  380.   %seconds = $calc(%temp % 60)
  381.   if (%seconds != 0) %age = %age and %seconds second $+ $iif(%seconds > 1,s)
  382.   if ($right(%age, 1) == $chr(44)) return $left(%age, -1)
  383.   return %age
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement