dougscripts.com

iTunes 7.2

iTunes 7.2 was released on May 30, 2007. It mostly provides support for DRM-free (copy-protection-free) purchases from the iTunes Store.

 

New command

iTunes 7.2 has introduced a new reveal command. Given a reference to a track or a playlist, the reveal command will select that track or playlist in iTunes. Here is some example syntax:

-- select the currently playling track
tell application "iTunes"
	reveal current track
end tell

-- select a specific track 
tell application "iTunes"
	reveal (track "Woo Hoo" of playlist "Music")
end tell

-- select a playlist
tell application "iTunes"
	reveal playlist "Music"
end tell
-- note that setting the view of the front browser window  to playlist "Music"
-- works similarly

There are limitations. For instance, only one track can ever be revealed, so a track reference using whose or where queries that produces more than one result will not reveal all the results.

Other changes

The persistent id property of a track or playlist (any item really) is now a string (the one in the XML file), rather than a floating-point number like this: -3.61825200699E+18. Using the library's persistent id and a track's persistent id should enable you to locate a track's artwork .itc file, which uses those two numbers in its filename. Here's something I banged together to locate the .itc file for a single selected track (could be neater, sorry):

tell application "iTunes"
	set sel to selection
	if sel is not {} and (count of sel) is 1 then
		set the_track to item 1 of sel
		set theLib to container of container of the_track
		set p1 to persistent ID of theLib
		tell the_track to set p2 to persistent ID
	else
		display dialog "Select a single track..." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
	end if
end tell

set start_of_path to ((path to music folder as string) & "iTunes:Album Artwork") as string
log ("start_of_path: " & start_of_path)

set the_filename to (p1 & "-" & p2 & ".itc") as string
log ("the_filename: " & the_filename)

set rez to (do shell script "find " & quoted form of POSIX path of start_of_path & " -name " & quoted form of the_filename) as string
log ("rez: " & rez)

if rez is not "" then
	if rez contains return then
		set thePath to POSIX file (item 1 of text_to_list(rez, return))
	else
		set thePath to POSIX file rez as string
	end if
	
	set thePath2 to (start_of_path & text ((offset of "Music:iTunes:Album Artwork:" in thePath) + 26) thru -1 of thePath) as string
	log ("thePath2: " & thePath2)
	
	tell application "Finder"
		reveal file (thePath2)
		activate
	end tell
	
else
	display dialog "No Artwork for this file"
end if

on text_to_list(txt, delim)
	set saveD to AppleScript's text item delimiters
	try
		set AppleScript's text item delimiters to {delim}
		set theList to every text item of txt
	on error errStr number errNum
		set AppleScript's text item delimiters to saveD
		error errStr number errNum
	end try
	set AppleScript's text item delimiters to saveD
	return (theList)
end text_to_list

Note that artwork for albums released on the iTS is encrypted as of around October 2006.

More as it develops...

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.