Advertisement
westor

ITunes rating script for patrick v3.0

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