Advertisement
westor

ITunes rating script for patrick

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