ALERT: iTunes 4.7 AppleScripting Changes

GO TO ADMIN PANEL > ADD-ONS AND INSTALL VERTIFORO SIDEBAR TO SEE FORUMS AND SIDEBAR
Joined
Jul 1, 2003
Messages
705
Points
0
Location
Providence, RI, USA
Website
dougscripts.com
The latest iTunes 4.7 release has apparently changed the way the selection object is targeted. No longer can you simply get the application selection, you must target the particular window's selection. This means that any script which simply targeted the selection will have to be re-written to target the front browser window's selection. So rather than do this:
Code:
tell application "iTunes"
        get selection
end tell
You must do this:
Code:
tell application "iTunes"
        set win to front browser window
        tell win
                get selection
        end tell
end tell
This makes sense, but it doesn't make sense that the application selection object is no longer available...or if it is, what is it?

Many scripts will need to be re-written!
 
Joined
Jul 1, 2003
Messages
705
Points
0
Location
Providence, RI, USA
Website
dougscripts.com
Furthermore

OK, maybe I panicked.

It seems that many of my compiled scripts which use the application selection object (as in the first example above) do work correctly, when run from iTunes' Script menu. However, running that first snippet in Script Editor returns an empty list. Also, I've noticed that at least one script saved as an application using application selection fails as well. I haven't had time to test very many scripts, so I'm still not exactly sure which circumstances work OK and if this is a bug or a feature.

It does seem to me, however, that targeting a window's selection makes more "script sense".
 

Reinklang

New member
Joined
Oct 28, 2004
Messages
3
Points
0
Thanks for this important info. Just had to find it out myself yesterday when I tried "Put this after That" from the script menu in 4.7. However, even the modification mentioned above did not fix the problem! I am still getting a "no tracks are selected" message. I'm not an AppleScript expert, so maybe it was my mistake. Any suggestions?
 
Joined
Jul 1, 2003
Messages
705
Points
0
Location
Providence, RI, USA
Website
dougscripts.com
Yep

Yes, those scripts seem to be a problem. I hope to update them myself very soon.

It appears that when the application selection is used outside of iTunes--if you will--that is, either from Script Editor or as part of a script saved as an application, the error occurs. Compiled scripts run from iTunes' Scripts menu seem OK (which is a great relief!) Therefore, its only problematic when testing scripts in Script Editor or when running applicatioin scripts.

I have notified Apple and I am waiting to hear of a confirmation of the--I guess--bug.
 

scottzero

New member
Joined
Oct 29, 2004
Messages
1
Points
0
thoughts behind the applescript changes

my first impression on these applescript changes in 4.7 (given that 4.7 disabled the Ipod Download plugin) is that they're attepting to make it difficult to applescipt ipod->itunes music xfers. i don't have an ipod so i don't know if that script broke.

.zero

btw, i'm waiting for doug's changes to this/that scripts. i use swaping regularly. can i get an uncomplied and do it myself?

.scott
 
Joined
Jul 1, 2003
Messages
705
Points
0
Location
Providence, RI, USA
Website
dougscripts.com
I've updated This Tag, That Tag Scripts, Import iPod Audio Files, and New iPod Playlist From Selection, which are affected by the iTunes 4.7 "selection bug".

I realise there are more that are affected. Mostly these will be application scripts (applets) that target plain old selection. Users can edit affected scripts by making sure that any reference in the script to selection (there could be more than one) is edited to refer to selection of front browser window.
 

Reinklang

New member
Joined
Oct 28, 2004
Messages
3
Points
0
Wow! That was quick. Thanks for taking care of this so fast. The new versions work fine in 4.7. BTW: a big compliment to your site and your work with these scripts. I couldn't imagine how helpful these would be until I started tranferring my entire CD collection.

Great Job!
 

ajpruett

Adam Pruett
Joined
Oct 18, 2003
Messages
14
Points
0
Thanks so much for updating these scripts! I tried editiing the scripts to set a new play count, and delete files from within a playlist. Since I don't know what I'm doing, I couldn't get them to work. Are updates planned on those as well?

Thanks again for all the hard work!
 

webjedi

New member
Joined
Nov 1, 2004
Messages
2
Points
0
Age
45
Website
soundtrack.net
iCal-Calling-iTunes

Doug, if you'r reading this, your script for iCal-calling-iTunes is also dead in the water after the iTunes 4.7 upgrade. JFYI, any chance on getting that compiled and posted on your site? (My radio station depends a bit on it) :) Thanks.

P.S. I've been working with the guys from Rogue Amoeba with issues regarding your script and Nicecast and wondered if there is a forum (e-mail, IM, or otherwise) where we can work on this. Thanks.
 
Last edited:

webjedi

New member
Joined
Nov 1, 2004
Messages
2
Points
0
Age
45
Website
soundtrack.net
iCal-calling-iTunes

Basically, it was a "Bad Parameter" call via running the script. The only thing that has changed between the two times where this was launched was the install of the latest round of Apple stuff, which was the Quicktime Update, iTunes 4.7, and the security patch from 10-27-04.

The calendar had stayed the same as well, so those where the three variables to the equation. Since you can manipulate the equation to fit those variables, I'll let the math be your job ;-)

Thanks Doug...

(P.S. - I think the guys at Live365.com will need your help in the future)
 

netdzynr

New member
Joined
Nov 30, 2004
Messages
3
Points
0
Age
54
More on "The Selection"

Along the lines of "the selection"... Is there any way to *set* the selection to designated tracks using AS? I've come across dozens of scripts that *retrieve* the selection, and several that select a range of items within a variable, but I haven't seen any code that allows you to specify which line items (tracks) are selected (highlighted) in a playlist. If one can get the selection, one should be able to set the selection as well, yes?

Thanks for any suggestions.
 

aribn

New member
Joined
Dec 14, 2004
Messages
1
Points
0
another solution

If you first "activate" iTunes, you can still get the application's selection. The following code works in both the iTunes Script menu and in the Script Editor.

Code:
tell application "iTunes"
     activate
     get selection
end tell
 
Joined
Jul 1, 2003
Messages
705
Points
0
Location
Providence, RI, USA
Website
dougscripts.com
Re: another solution

That's very interesting! Nice discovery. It seems to confirm the effect I talked about earlier (I think I mentioned it here) whereby scripts run "outside" of iTunes will fail getting the selection.

Of course, one doesn't always want iTunes frontmost when a script is running, so this solution, while elegant, is not always desirable. Even so, good option to know.
 

mac youzer

New member
Joined
Dec 21, 2004
Messages
1
Points
0
Fix for "Copy as MP3 from Start to Stop"

That script (to break up MP3s into shorter files according to the begin playing and stop playing settings in iTunes) was also broken by the 'selection' change in 4.7.

So, per above, just add two lines to the beginning of the script after the 'tell applicatiaon iT get selection'

i.e. change the first lines of the script so it starts as follows:

tell application "iTunes"
activate
set oldEncoder to (get current encoder)
tell me to set_encoder()

get selection

(continues with: if (count every item) of selection is 1 then
and so on
 
Top