Advertisement
westor

ITunes rating script for patrick v2.0

Nov 15th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.77 KB | None | 0 0
  1. ON !*:TEXT:!*:#: {
  2.   tokenize 32 $strip($1-)
  3.   if ($1 == !song) { itunes }
  4.   if ($1 == !rate) {
  5.     if (!$2) { .msg $chan [ $+ $nick $+ ]: Error, Not enough parameters, try again and enter the number! | return }
  6.     if ($2 !isnum) { .msg $chan [ $+ $nick $+ ]: Error, Incorrect parameters, try again and enter only numbers! | return }
  7.     if ($2 > 5) { .msg $chan [ $+ $nick $+ ]: Error, Too high, try again and use an smaller number 1-5 only permitted! | return }
  8.     setrating_command $chan $nick $2
  9.   }
  10. }
  11.  
  12. alias setrating_command {
  13.   if (!$1-) { return }
  14.   var %p = iTunes, %i = IITTrack
  15.   .comopen iTunes iTunes.Application
  16.   if ($comerr) { .timeriTunes off | goto error }
  17.   if $com(%p,CurrentTrack,3,dispatch* %i) {
  18.     if (!$com(%i)) {
  19.       .msg $1 [ $+ $2 $+ ]: Error, NOT any track is currently has been selected.
  20.       goto error
  21.     }
  22.     var -s %info = $com(%i,Rating,4,long).result
  23.     var -s %k = $com(%i,Rating,4,long,$calc($3 *20))
  24.     var -s %k = $com(%i,Name,2)
  25.     var -s %n = $com(%i).result
  26.     .msg $1 [ $+ $2 $+ ]: Song ratings for $qt(%n) has been changed to $qt($3) $+ .
  27.   }
  28.   :error
  29.   while ($com(0)) { .comclose $com(1) }
  30. }
  31.  
  32. alias get_rate {
  33.   .comopen Rating iTunes.Application
  34.   if ($comerr) { goto error }
  35.   if ($com(Rating,CurrentTrack,3,dispatch* Track)) {
  36.     if (!$com(Track)) { goto error }
  37.     var -s %k = $com(Track,Rating,2)
  38.     var -s %n = $com(Track).result
  39.   }
  40.   :error
  41.   while ($com(0)) { .comclose $com(1) }
  42. }
  43.  
  44. ;; checkForItunes - Should return $true if you want to use the
  45. ;; -- chkprog alias to see if iTunes is running before each
  46. ;; -- command. Slows the program down slightly, but the script
  47. ;; -- will not run iTunes if it is not open. If $false, the
  48. ;; -- script will run slightly faster and it will assume the
  49. ;; -- user knows whether or not iTunes is open, and due to
  50. ;; -- the COM interface, will run iTunes if it is not open.
  51. ;alias -l checkForITunes { return $false }
  52.  
  53. ;; useTimer - Should return $true if you want the iTunes script
  54. ;; -- to run periodically, i.e. every 480 seconds. If $false,
  55. ;; -- no timers will be run.
  56. ;alias -l useTimer { return $false }
  57.  
  58.  
  59. ;; doNotMessageChans -- This should be a space delimited list of
  60. ;; -- channels you do not want the script to message. By default
  61. ;; -- the script will message your active channel, so if one of
  62. ;; -- these channels is your active channel, it will do nothing
  63. ;; -- Syntax: #chan1 #chan2 #chan3 #chanN
  64. alias -l doNotMessageChans { return #irchelp #rsmarket }
  65.  
  66. ;; period -- Edit the number to the number of seconds you want
  67. ;; -- as a delay between automatic messages.
  68. ;alias -l period { return 480 }
  69.  
  70. alias itunes {
  71.   _iTunes
  72. }
  73. alias itunesoff {
  74.   .timeriTune* off
  75.   echo -at $+ **   $+ iTunes timer stopped.
  76. }
  77. alias _itunes {
  78.   scid $activecid
  79.   var %p = iTunes, %i = Track, %b = $chr(2), %% = $+(%b,,-,$chr(3),%b)
  80.   .comopen iTunes iTunes.Application
  81.   if ($comerr) { .timeriTunes off | goto error }
  82.   if $com(%p,CurrentTrack,3,dispatch* %i) {
  83.     if (!$com(%i)) { echo -at  $+ **  $+  No track is currently playing. | goto error }
  84.     var %k = $com(%i,Name,2)
  85.     var %name = $com(%i).result
  86.     var %k = $com(%i,Album,2)
  87.     var %album = $com(%i).result
  88.     var %k = $com(%i,Artist,2)
  89.     var %artist = $com(%i).result
  90.     var -s %k = $com(%i,Rating,2)
  91.     var -s %n = $com(%i).result
  92.     var -s %rating = $+($str(*,$calc(%n /20)),%b,$str(-,$calc(5 - (%n /20))),%b)
  93.     var %position = $regsubex($asctime($com(%p).result,n:ss),/(\d+):(\d+)/,$+(\1,,:,,\2))
  94.     var %pr = $calc($com(%p).result / $com(%i).result)
  95.     var %k = $com(%p,PlayerState,2)
  96.     var %st = $com(%p).result
  97.     var %k = $com(%i,PlayedCount,2)
  98.     var %played = $com(%i).result
  99.     var %msg = %name $iif(!%st,(Paused))
  100.     $iif(%artist,%% %artist)
  101.     $iif(%album,%% Album %album)
  102.     %% Played %played $+ $chr(15) times
  103.     %% Rating %rating
  104.     $iif($active ischan && !$istok($doNotMessageChans,$active,32),msg $active,noop) $iif(c !isincs $chan($active).mode,%msg,$strip(%msg,c)))
  105.   }
  106.   :error
  107.   while ($com(0)) { .comclose $com(1) }
  108. }
  109.  
  110. alias setrating {
  111.   if (!$1) {
  112.     echo -at $c1 $+ ** $it $c2 $+ Please specify a rating to give this song, between 0 and 5 inclusive.
  113.     return
  114.   }
  115.   var %p = iTunes, %i = IITTrack
  116.   .comopen iTunes iTunes.Application
  117.   if ($comerr) { .timeriTunes off | goto error }
  118.   if $com(%p,CurrentTrack,3,dispatch* %i) {
  119.     if (!$com(%i)) {
  120.       echo -at $c1 $+ ** $it $c2 $+ No track is currently selected.
  121.       .timeriTunes off
  122.       goto error
  123.     }
  124.     var %k = $com(%i,Rating,4,long,$calc($1 *20)), $&
  125.       %k = $com(%i,Name,2), %n = $com(%i).result
  126.     echo -at $c1 $+ ** $it $+($c2,Rating for:,$c1,$chr(32),%n,$chr(32),$c2,changed to,$c1,$chr(32),$1,$c2,.)
  127.   }
  128.   :error
  129.   while ($com(0)) { .comclose $com(1) }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement