Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

iTunes Integration into mIRC [Now Playing +more]

Recommended Posts

  • Administrators

iTunes Integration into mIRC [Now Playing +more]

 

This is a simple iTunes script, no dialog just some aliases. I was nagged to death about releasing this by certain parties who will remain unnamed. After I wrote this one, I looked on the forum to see if there is any competetion and only found one other iTunes script. (I didn't feel like releasing mine because I thought there was already several here). Ignore the timestamps, I didn't feel like editing them to make it more realistic, yes I know they're all exactly the same. Note: Some parts of these scripts are CPU intensive, so I advise you don't spam them

 

Anyway, the script:

 

/iTunes:

 

If iTunes is not open, you will be prompted [yes/no] to run it if you set the checkForITunes option to $true. If you chose to run iTunes, let iTunes finish opening, select the music you want to play, and type /iTunes again

 

If you chose to set the useTimer option to $true, the alias triggers a timer that will message the active channel what you are listening to every 480 seconds (easily edited to something else via the period option). The colors on all the scripts are easily customizable by editing the color aliases [c1,c2,c3,c4]. I would avoid using white or black as colors, considering many people have white/black as their background and whatever is that color will not show up for them. I've color coded all the examples so you can see what the script output looks like. Color 1 is orange[07], color 2 is dark gray[14], color 3 is red[04], and color 4 is light blue[12].

 

 

 

/pause and /resume:

Use these two aliases to pause and resume the current song respectively.

 

/setrating:

Use this alias to change the Rating of the currently playing song, goes from 0 to 5 (stars). It's the same setting as on your iPod or in the iTunes Media Library. Change it here and it will change there. The default rating for all songs is 0.

 

/_iTunes:

 

Notice the underscore. You can use this to show what song you are listening to NOW instead of waiting for the timer to set off.

 

----------------------------------------

 

Places to edit:

 

There are always places to edit in scripts, for colors or whatnot.

 

In the first four lines, you can find your color aliases. Tweak the numbers in the aliases to change the colors of the script.

 

In the "L" (one L) alias, you can change the seperator which is by default a double arrow (»). Just swap it out in the alias for something else if you wish.

 

Look for the option doNotMessageChans. Change the return value of that alias to whatever chans you don't want the script to message. Syntax is $doNotMessageChans = #chan1 #chan2 ... #chanN. For example, that line may look to you like:

 

alias doNotMessageChans { return #chan1 #chan2 #chan3 }

 

In the period option, you can change "480" to any other number value you want, but I advise it stay above 180 [3 minutes] because it can get spammy. The value is in seconds not minutes.

 

If you don't like an hourglass popping up as your mouse pointer whenever the alias runs, you can remove or "nerf" the chkprg alias. This can be done quite easily by changing the checkForItunes option to $false. - note: I don't want anyone to post a modified script which has the chkprg alias removed, it's unnecessary).

 

----------------------------------------

 

Other Stuff:

 

Just a couple notes for you, if you have other color aliases in the same file there will be a conflict, so put this script in a seperate file. I know James likes to do color aliases a lot so there's potential problems.

 

The chkprg alias was made for my by Champagne, I don't know much VB but basically that alias writes all the currently running processes (task manager -> processes) into a text file. I made it so it checks if $1 (iTunes.exe in this case) is in the file and thereby running.

 

I just found it annoying for iTunes to run when you didn't want it do (maybe you closed iTunes but forgot to end the timer). With that alias that won't happen(unless you disabled that with the snippet above). Thanks Champagne. He said he released it but I don't see it in this forum anywhere so :s

 

----------------------------------------

 

Revision 2011:

 

I randomly made a few revisions about some things I noticed over the years, just some polish stuff that I should have taken care of in the first place. I was going to change the music that I used as examples but I decided it wasn't worth the trouble. I hate all that music now.

•Made it easier to edit the options for the script, no commenting is necessary

•Made the timer opt-in instead of opt-out

•Made the chkprog opt-in instead of opt-out

•Added more error messages

•Added $iifs to check if the Genre/Artist/etc is even specified, not everyone's iTunes is like mine

•Made it only write the pro.vbs program when it is not already in the mIRC directory (and its filesize is 294, in case it has been modified somehow)

•Added some documentation to the options so the user does not need to look at this post for help

 

----------------------------------------

 

>;;----------------------------------------------------------;;;; iTunes script by Kvn Pfc :: http://rseos.com/EchoScript/ ;;;;              Revised Version August 2011                 ;;;;----------------------------------------------------------;;;;----------------------------------------------------------;;;;                         Options                          ;;;;            Edit these lines to your preference           ;;;;----------------------------------------------------------;;;; checkForItunes - Should return $true if you want to use the;; -- chkprog alias to see if iTunes is running before each ;; -- command. Slows the program down slightly, but the script ;; -- will not run iTunes if it is not open. If $false, the ;; -- script will run slightly faster and it will assume the;; -- user knows whether or not iTunes is open, and due to;; -- the COM interface, will run iTunes if it is not open.alias -l checkForITunes { return $false };; useTimer - Should return $true if you want the iTunes script;; -- to run periodically, i.e. every 480 seconds. If $false, ;; -- no timers will be run.alias -l useTimer { return $false };; doNotMessageChans -- This should be a space delimited list of;; -- channels you do not want the script to message. By default;; -- the script will message your active channel, so if one of;; -- these channels is your active channel, it will do nothing;; -- Syntax: #chan1 #chan2 #chan3 #chanNalias -l doNotMessageChans { return #irchelp #rsmarket };; period -- Edit the number to the number of seconds you want;; -- as a delay between automatic messages. alias -l period { return 480 };; Colors - Change the double digit numeric to modify the colors;; -- used in the iTunes script. Play around with it until you;; -- find what you like.alias -l c1 { return $+($chr(3),07) }alias -l c2 { return $+($chr(3),14) }alias -l c3 { return $+($chr(3),04) }alias -l c4 { return $+($chr(3),12) };; Text separators - These are totally up to you, I recommend;; -- keeping these fairly simple. Modification is not actually;; -- necessary.alias -l l { return $+($chr(2),$c3,»,$chr(3),$chr(2)) }alias -l ll { return $+($c2,$1-,$c3,:,$c1) }alias -l it { return $+($c2,[,$c4,iTunes,$c2,],$chr(2),$c3 —›,$chr(2)) }alias -l lll { return $+($c2,[,$c1,$1-,$c2,]) };; End Options ---------------------------------------------;;;; Begin Script --------------------------------------------;;alias itunes {   _iTunes  if ($useTimer) { .timeriTunes 0 $period noop $!_itunes }}alias itunesoff {   .timeriTune* off  echo -at $c1 $+ ** $it $c2 $+ iTunes timer stopped.}alias _itunes {  if (!$chkprg(iTunes.exe)) {     if (!$isid) {      var %x = $?!="Would you like to run iTunes?"      if (%x) { run iTunes.exe | echo -at $c1 $+ ** $it $+($c2,Now running,$chr(32),$c1,iTunes.exe,$c2,. Type /itunes again when iTunes finishes opening and you have started playing music.) }      else { echo -at $c1 $+ ** $it $+ $c2 No action taken.  }    }    .timeriTune* off     return  }  scid $activecid  var %p = iTunes, %i = IITTrack, %b = $chr(2), %% = $+(%b,$c3,»,$chr(3),%b)  .comopen iTunes iTunes.Application  if ($comerr) { .timeriTunes off | goto error }  if $com(%p,CurrentTrack,3,dispatch* %i) {    if (!$com(%i)) { echo -at $c1 $+ ** $it $+ $c2 No track is currently playing. | goto error }    var %k = $com(%i,Name,2)    var %name = $com(%i).result    var %k = $com(%i,Album,2), %album = $com(%i).result, $&      %k = $com(%i,Artist,2), %artist = $com(%i).result, $&      %k = $com(%i,BitRate,2), %bitrate $com(%i).result, $&      %k = $com(%i,Time,2), %time = $regsubex($com(%i).result,/(\d+):(\d+)/,$+(\1,$c2,:,$c1,\2)), $&      %k = $com(%i,Rating,2), %n = $com(%i).result, $&       %rating = $+($str(¤,$calc(%n /20)),%b,$str(-,$calc(5 - (%n /20))),%b), $&      %k = $com(%i,Year,2), %year = $com(%i).result    var %k = $com(%i,Duration,2), %k = $com(%p,PlayerPosition,2), $&      %position = $regsubex($asctime($com(%p).result,n:ss),/(\d+):(\d+)/,$+(\1,$c2,:,$c1,\2)), $&      %pr = $calc($com(%p).result / $com(%i).result), $&      %progress = $+(%b,$chr(3),4,$str(¦,$floor($calc(%pr *10))),$chr(3),1¦,$chr(3),3,$str(¦,$calc(10- $round($calc(%pr *10),0))),%b,$c2), $&      %k = $com(%p,PlayerState,2), %st = $com(%p).result, $&      %k = $com(%i,Genre,2), %genre = $com(%i).result, $&      %k = $com(%i,PlayedCount,2), %played = $com(%i).result    var %msg = $it $ll(Track) %name $iif(!%st,$lll(Paused)) $&      $iif(%artist,%% $ll(Artist) %artist $iif(%year,$lll(%year))) $&      $iif(%album,%% $ll(Album) %album) $&      %% $ll(Position) $+(%position,$c2,/,$c1,%time) $&      $lll($calc($round(%pr,2) *100) $+ %) $+([,%progress,]) $&      %% $ll(Rating) %rating $&      %% $ll(Bitrate) $+(%bitrate,$c2,kbps) $&      $iif(%genre,%% $ll(Genre) %genre) $&      %% $ll(PlayedCount) %played $+ $chr(15)    $iif($active ischan && !$istok($doNotMessageChans,$active,32),msg $active,noop) $iif(c !isincs $chan($active).mode,%msg,$strip(%msg,c)))  }  :error  while ($com(0)) { .comclose $com(1) }}alias pause {  if (!$chkprg(iTunes.exe)) { return }  .comopen iTunes iTunes.Application  noop $com(iTunes,Pause,3)  echo -at $c1 $+ ** $it $c2 $+ Music Paused.  .comclose iTunes}alias resume {  if (!$chkprg(iTunes.exe)) { return }  .comopen iTunes iTunes.Application  noop $com(iTunes,Play,3)  echo -at $c1 $+ ** $it $c2 $+ Music Resumed.  .comclose iTunes}alias setrating {  if (!$1) {    echo -at $c1 $+ ** $it $c2 $+ Please specify a rating to give this song, between 0 and 5 inclusive.    return  }  var %p = iTunes, %i = IITTrack  .comopen iTunes iTunes.Application  if ($comerr) { .timeriTunes off | goto error }  if $com(%p,CurrentTrack,3,dispatch* %i) {    if (!$com(%i)) {      echo -at $c1 $+ ** $it $c2 $+ No track is currently selected.      .timeriTunes off      goto error    }    var %k = $com(%i,Rating,4,long,$calc($1 *20)), $&      %k = $com(%i,Name,2), %n = $com(%i).result    echo -at $c1 $+ ** $it $+($c2,Rating for:,$c1,$chr(32),%n,$chr(32),$c2,changed to,$c1,$chr(32),$1,$c2,.)  }  :error  while ($com(0)) { .comclose $com(1) }}alias next {  if (!$chkprg(iTunes.exe)) { return }  var %p = iTunes, %i = IITTrack  .comopen iTunes iTunes.Application  if ($comerr) { .timeriTunes off | goto error }  if $com(%p,CurrentTrack,3,dispatch* %i) {    var %k = $com(%p,NextTrack,3)    .timer 1 .5 _next  }  :error  while ($com(0)) { .comclose $com(1) } }alias back {  if (!$chkprg(iTunes.exe)) { return }  var %p = iTunes, %i = IITTrack  .comopen iTunes iTunes.Application  if ($comerr) { .timeriTunes off | goto error }  if $com(%p,CurrentTrack,3,dispatch* %i) {    var %k = $com(%p,PreviousTrack,3)    .timer 1 .5 _back  }  :error  while ($com(0)) { .comclose $com(1) } }alias -l _back {  var %p = iTunes, %i = IITTrack  .comopen iTunes iTunes.Application  if ($comerr) { .timeriTunes off | goto error }  if $com(%p,CurrentTrack,3,dispatch* %i) {    var %k = $com(%i,Name,2)     echo -at $c1 $+ ** $it $+($c2,Advanced to previous track:,$c1) $com(%i).result   }  :error  while ($com(0)) { .comclose $com(1) } }alias -l _next {   var %p = iTunes, %i = IITTrack  .comopen iTunes iTunes.Application  if ($comerr) { .timeriTunes off | goto error }  if $com(%p,CurrentTrack,3,dispatch* %i) {    var %k = $com(%i,Name,2)     echo -at $c1 $+ ** $it $+($c2,Advanced to next track:,$c1) $com(%i).result   }  :error  while ($com(0)) { .comclose $com(1) } }alias chkprg {  if (!$checkForITunes) { return $true }  if ($file(pro.vbs) != 294) {    .fopen -o processes processes.txt    .fclose processes    var %% = aline @@, %x = processes.txt    window -h @@    %% Dim z, x, t    %% Set z = CreateObject("Scripting.FileSystemObject")    %% Set x = z.OpenTextFile(" $+ $mircdir $+ %x $+ ", 2, 1)    %% t = "."    %% For Each obj In GetObject("winmgmts://" & t & "/root/cimv2").ExecQuery("SELECT * FROM Win32_Process")    %% x.Write(obj.Description & vbCrLf)    %% Next    savebuf @@ pro.vbs    window -c @@  }  .comopen q wscript.shell    .comclose q $com(q,run,3,bstr,wscript " $+ $mircdir $+ pro.vbs",uint,5,bool,true)  return $read(processes.txt,r,$1) };; End Script ----------------------------------------------;;

Link to comment
Share on other sites



×
×
  • Create New...