dougscripts.com

AppleScript Changes in iTunes 4.1

iTunes 4.1 was released on October 16, 2003 as part of Apple's unveiling of iTunes for Windows. Also announced were new iPod accessories and many iTunes Music Store enhancements and promotions. Also released, but I don't believe mentioned, was QuickTime 6.4

 

Shared

The user playlist class has a new property called shared. It takes a boolean value:

tell application "iTunes"
	set thisP to view of front window
	set shared of thisP to true
	-- check your work
	log (get shared of thisP)
end tell

[upm]

Now, if you have your Sharing Preferences set to "Share my music" you can assign (set) a user playlist to be shared over the local network—it's the AppleScript equivalent of checking the boxes next to a playlists's name in the Shared Preferences. If "Share entire library" is checked, then shared has no affect.

However, if "Share my music" is UNchecked, you can't set shared because of a file permission error (-54). At least, I couldn't. You can still get shared.

Play Counts

Holy cow! The track property played count is no longer read-only and is now set-able. Which means you can set your played count to any integer. This example sets the first track of the selected tracks to 201 plays:

tell application "iTunes"
	set t to get item 1 of selection
	set played count of t to 201
end tell

[upm]

Also, the track property played date, the date the track was last played from beginning to end, is also get- and set-able. It takes a date string, which is a bit too complex to describe here. Read more about date here.

Stream info

Other new additions are the current stream title and current stream URL properties of application, which will exist if the streamer makes them available. For example:

tell application "iTunes"
	if current stream title is not missing value then
		display dialog "You are listening to " & current stream title
	end if
end tell

[upm]

It will be missing value if the stream server neglects to make this info available.

CD Track Count and Number

The track count and track number properties of audio CD track are now read-only, which means you can't set them as you could in previous versions. You can't even set them by-hand in a track's Get Info window. While this makes sense—why would you want to alter the track ordering of CD tracks whose order is "written in stone"?—it may trouble some pre-4.1 scripts which access these properties. Here is a discussion at iPodlounge on the topic.

Assign Shortcut Keys to AppleScripts

Not an iTunes 4.1 tip, but a Panther tip: you can assign your own keyboard shortcuts to iTunes AppleScripts. Read how here.

Fixes

Finally, the misnamed s track of version 4.0.1's Dictionary has been fixed to correctly read device track.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.