Hacking Your iPod With Perl

Album Cover: First Impressions of Earth

"Don't be a coconut. God is trying to talk to you."
The Strokes / Ask Me Anything

Posted on July 24, 2005 7:47 PM in Programming
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

After initially playing around with the iTunes SDK while developing in C++, I checked out a more recent version of the SDK and found that supported languages included C# and Perl. Being the Perl hacker wannabe that I am, I decided to give hacking my iPod a whirl.

The final result is a Perl script called ipod.pl that, if nothing else, shows you how you can hack your own iPod using Perl.

Setup was simple. I just had to make sure my copy of Cygwin included the libwin32 library for Perl. It didn't, but thanks to Cygwin's handy package updating feature, it was a snap to retrieve. The only other real requirement is that you have your iPod attached to your PC and you've got a copy of iTunes installed.

The script I wrote, which is now available in all its glory, simply grabs a handle on the iTunes application, grabs some high-level information about the attached iPod, finds the largest playlist (note the assumption here that the largest playlist is always the main iPod playlist), and then spins through the tracks in that playlist to find the top 5 most played tracks.

Here's a screenshot of the output:

Screenshot of ipod.pl Perl Script Output

Unfortunately, it looks like the play count for a track in your iPod is only incremented when you play it in iTunes, so I don't think it's a real representation of the number of times you've listened to the song. However, the real purpose of this script is to show how easy it is to start querying the iTunes SDK and finding out information about your iPod or even controlling it – that's right, you can play a track, rewind a track, play a playlist, etc. I think this is where somebody could get really creative. I've only scratched the surface.

If you have questions about the script or know of any cooler applications of this functionality, either leave a comment or drop me an email.

Comments

Ryan on July 25, 2005 at 12:30 AM:

iTunes is the devil.

Welcome back to the blogosphere, we missed you.

Permalink

vector logo design service on October 03, 2016 at 11:36 PM:

Thank you for taking the time to publish this information very useful!

Permalink

Post Comments

If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.

Name:

Email Address:

Website:

Comments:

Check this box if you hate spam.