Create Links to the iTunes Music Store

Send your friends a link to that new song you love and make it easy for them to buy it, all in one click.

One of the many brilliant (yes, brilliant) things about the iTunes Music Store is that, even though it is its own application, Apple has built some web-like functionality into it. Want to go back a page? Use the same key-board shortcut you would use in Safari,

image with no caption

-[.

As discussed in “Get at iTunes Music Store Metadata” [Hack #71] , the Music Store uses web-friendly conventions such as XML. Even though the iTunes Music Store functions outside the paradigm of the World Wide Web, Apple has made it easy to create links to its store. The store-specific hyperlinks can be embedded in HTML web pages or emailed along to a friend, just like any other URL. The difference is that when your friend clicks on the URL, her web browser won’t open. Instead, iTunes will open up on her machine and go to the Music Store and the artist or song to which you linked. Of course, this requires that your friend has iTunes on her machines, but who doesn’t these days?

The quickest way to get a link is to Control-click or right-click on a song in the iTunes Music Store. A contextual menu pops up. Select Copy iTunes Music Store URL and simply paste the URL into an email or HTML page. Apple also provides a link-maker that lets you quickly create links through the Web (http://www.apple.com/itunes/linkmaker/). Link Maker provides not only the iTunes URL, but also the wrapper HTML and the link to the album cover image. This is great if you want to post a few of your favorite songs or albums on your blog. The cover art shows up, and when users click on it they will be sent to the iTunes Music Store, where they can purchase that song/album.

The first page of the Link Maker lets you search by song, album, or artist name, as shown in Figure 4-46.

Let’s go ahead and enter “Hancock” in the artist field. iTunes Link Maker spits back all the Hancock songs that are on the iTunes Music Store and categorizes them by song, album, and artist. Notice that at the end of each category column is that now-familiar iTunes arrow. Link Maker gives you three options for creating links: you can link directly to a song, an album, or an artist. Click on the corresponding arrow, and Link Maker will create code specific to the category. In other words, if you want a link to the Herbie Hancock artist page on the iTunes Music Store, click on the Artist arrow. Want to link to a specific album? You guessed it; hit the arrow next to the album title. A song link will take a user to the album and will highlight the selected song.

The iTunes Link Maker main page

Figure 4-46. The iTunes Link Maker main page

Make your selection by clicking on the appropriate arrow. As shown in Figure 4-47, I’ve decided to link to the Herbie Hancock song “Shooz,” which appears on “Dis is Da Drum.” Link Maker provides the HTML code for the link. To use it, simply copy and paste the code into your HTML page.

You can use the code in a few ways. Figure 4-48 shows a couple different options. The code that Link Maker spits out is an image surrounded by an href tag. Apple expects you to use it like the first sentence in Figure 4-48— “I love this album by Herbie Hancock”—with the button right after. However, you can also use it as a regular web link by stripping out the button image and replacing it with your copy, as the second example shows. Finally, check out that sweet iTunes Download button!

If you want to quickly inform a friend of a new song you’ve discovered, copying the URL from iTunes and pasting it into an instant message (IM) is the way to go. If you want to show all the readers on your blog a new song, artist, or album you’ve discovered, use the Link Maker. Happy linking!

Copying and pasting the provided code to your web page

Figure 4-47. Copying and pasting the provided code to your web page

iTunes links on a web page

Figure 4-48. iTunes links on a web page

Get iPod and iTunes Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.