I hate having to use the iTunes interface directly. It’s slow. It’s annoying. It’s not macro-friendly.
So last night I decided to throw together some code to grab featured items from the iTunes Music Store and show them all together in Safari. From the command line. With working links, of course.
This way, I can see what’s there, avoid iTunes and search visually for the Singles of the Week, and any other items marked with the yellow FREE triangle. Once found, I click ‘em up right into the store.
Here it is. It only works with the US Store right now. Can anyone tell me how to directly get the feeds from other countries? Got any fixes, improvements or suggestions? What do you think of this utility? Let me know in the comments.
#! /usr/bin/perl
# US Only, Erica Sadun, 4 April 2006
@whichones = (20, 50000024, 2, 4, 5, 3, 6, 17, 7, 10, 18, 22, 11, 12, 14, 15, 24, 21, 16, 32, 23, 19);
%genrenames = (20, "Alternative", 50000024, "Audiobooks", 2, "Blues", 4, "Children's Music", 5, "Classical", 3, "Comedy", 6, "Country", 17, "Dance", 7, "Electronic", 10, "Folk", 18, "Hip-Hop/Rap", 22, "Inspirational", 11, "Jazz", 12, "Latin", 14, "Pop", 15, "R&B/Soul", 24, "Reggae", 21, "Rock", 16, "Soundtrack", 32, "TV Shows", 23, "Vocal", 19, "World");
# 31, "Music Videos", 26, "Podcasts",
@riz = ();
# For each genre, grab the tags
foreach $item (@whichones)
{getGenre($item); push(@riz, "<br />"); print ".";}
print "done\n";
# Store into a Safari-readable file
open(XFILE, ">/tmp/itunesGenreRiz.html");
foreach $item (@riz) {print XFILE $item, "\n";}
close(XFILE);
# Open in Safari
`open /tmp/itunesGenreRiz.html`;
sub getGenre()
{
my $genreid = shift;
my $doit = "curl -s \"http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewGenre?genreId=$genreid\" | gunzip | grep \"a1.phobos.apple.com\" | grep -v x53 | grep GotoURL | grep draggingURL";
# Fetch Genre list from iTMS
my $gn = %genrenames->{$genreid};
push(@riz, "<h3>".$gn."</h3>");
my $genriz = `$doit`;
my @rizray = split("\n", $genriz);
foreach my $item (@rizray)
{
$item =~ s/.*<GotoURL.*draggingURL=/<a href=/;
$item =~ s/" url=.*http://a1/"><img src="http://a1/;
$item =~ s/</PictureView.*/</a>/;
push(@riz, $item);
}
}


Can you change the TIFF into something more web-friendly? You crashed my Opera!
Oh no! Poor Opera! (Sorry..)
Alas, the TIFF is native to the iTMS.
By the way, I've stuck a downloadable version of the utility here.
I don't think Josh means the TIFF in the script (though he may) - I think he probably means the TIFF in the article itself. (Which, for the record, shows up as alt text in Firefox for Windows. I can't check on my Mac right now, I'm at work.)
Right, there seems to be a problem with 0604iTunesPicscaled.tiff. Safari and Vienna both display it but report the error "TIFFReadDirectory: tiff data provider: Seek error accessing TIFF directory.\n", while Camino doesn't display it at all, just the file name.
I wish that it was easier to bookmark a artist or album.
Also, why can't someone who likes a certain brand of music choose that music for their "homepage" in iTunes?
uhhhh, TIFFs on a webpage?
come on now. you can try a bit harder.
Sorry about the TIFF. It was left over from doing book screen shots . I'll JPEG for the future, but I'm not sure what I can do now to fix things.
The German store doesn't have any free stuff, and the Canada store doesn't seem to use the triangles. I have a feeling trying to internationalize the script would be more work than it's worth.
Very cool!
You can also use the iTunes Music Store RSS Generator to set up up a custom RSS feed and then bookmark the feed in Safari or any RSS reader.
http://phobos.apple.com/WebObjects/MZSearch.woa/wa/MRSS/rssGeneratorInput
Rock on!
Almost all of that code can be done within Perl, instead of shelling out so much. It'd be a lot faster and safer that way too.