itmshack: Grab Album Description Text from the iTunes Music Store

by Erica Sadun

Today's iTunes Music Store Hack: downloading the text that accompanies an iTunes Music Store album. The text will generally include the album description and user reviews from the main album page. If you're a Unix weenie, you can think of this script as "strings" for the iTMS.

As always, this is a US music store hack only. If someone can help me figure out how to request listings from another storefront, please let me know.

I've taken some of Andy Lester's superb coding examples to heart here, but as always please feel free to suggest improvements. Enjoy.

#! /usr/bin/perl
# US Only, Erica Sadun, 14 April 2006
# Return the text for an album
# e.g. ./ 140812843
# or ./ 145852049

use warnings;
use strict;

if ($#ARGV < 0) {die "Usage: $0 AlbumID (StoreID)\\n";}

my $albumid = $ARGV[0];
my $url = "$albumid";

my $doit = qq{curl -s "$url" | gunzip};
my $riz = `$doit`;
my @riz = split("\\n", $riz);

foreach my $item (grep(/TextView/ , @riz))
$item =~ s/<[^>]*>//g;
$item =~ s/^ *//;
if ($item ne "") {print $item, "\\n";}

Download a copy of the code here.


2006-05-27 12:01:21
Apparently, other storefronts are selected via the X-Apple-Store-Front in the HTTP request. When I browse the Swiss store, iTunes adds the following header to the HTTP request:

X-Apple-Store-Front: 143459-2

The storefront number can be found by using "Copy iTunes Music Store URL" on an item. A parameter is added to the query:

The additional "-2" part seen in the header above selects the language. 1 and 2 are both English but slightly different, 3 is French and 4 is German, at least for the Swiss store. Omitting it gives you the default language (German).

You can add this header to your request by adding the following option to curl:

--header 'X-Apple-Store-Front: 143459-2'
brian d foy
2006-08-28 19:52:46
By changing viewAlbum to viewIMix (and giving it the right iMix ID, I made this work for those too. :)