Skip to Content
iPod and iTunes Hacks
book

iPod and iTunes Hacks

by Hadley Stern
October 2004
Beginner to intermediate
456 pages
12h 36m
English
O'Reilly Media, Inc.
Content preview from iPod and iTunes Hacks

Search the iTunes Music Store for the Current Song

Search the iTunes Music Store using info from the currently playing track.

You can search the iTunes Music Store (iTMS) using the handy link arrows associated with each track in the library. But this AppleScript hack lets you search the iTMS for the currently playing song, even if it’s playing from a stream.

The Code

The script gets tag info from the currently playing track and displays it in a listbox so the user can choose which tags to use as search criteria. The script then affixes the chosen data to a URL, which is sent to iTunes.

	-- get info from current track
	tell application "iTunes"
	  if player state is not stopped then
	    if class of current track is not URL track then
		  tell current track to set {alb, art, nom, com} to ¬
		    {album, artist, name, composer}
		else

		if current stream title is not "" then 
		  set {art, nom} to my text_to_list(current stream title, " - ")	
		  set {alb, com} to {"", ""}
        else 
		  display dialog "Can't get data from stream." buttons ¬ 
		    {"Cancel"} default button 1 with icon 0 giving up after 30 
		end if

	    end if	
	  else 
		display dialog "No track currently playing." buttons {"Cancel"} ¬ 
          default button 1 with icon 0 giving up after 30 
      end if 
	end tell

	-- build list to display in choose from list box 
	set theOptions to {"Song:" & tab & nom, "Artist:" & tab & art, ¬ "Album:" & tab & alb, "Composer:" & tab & com} -- display choose from ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

iPOD & ITUNES for Dummies Portable Edition

iPOD & ITUNES for Dummies Portable Edition

Tony Bove
Windows Server® 2008 Active Directory® Resource Kit

Windows Server® 2008 Active Directory® Resource Kit

Conan Kezema Stan Riemer Mike Mulcare, Byron Wright, and Microsoft Active Directory
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 0596007787Supplemental ContentErrata Page