tylerbutler.com
Wednesday, December 3 2008 @ 4:15 PM

Powered by Microsoft Office SharePoint Server 2007
Skip Navigation LinksTyler Butler.com / Life / Projects / iTunes Lyric Search
                                                  
iTunes Lyric Search 
Cross-reference your iTunes music collection with Lyrics search results from LetsSingIt.com.
I have a rather large music collection, including a lot of full albums. I haven't always heard every single song on the album. I also have an iPod Shuffle which I use when I run. I simply load it up with random music from my collection and put it ni shuffle mode. Inevitably, I come across songs that I really like that I don't recognize. I want to be able to tag them as 3, 4, or 5 stars in my iTunes DB so I can find them later, but since the Shuffle doesn't provide this, and because it doesn't have a display so I can tell the artist and song name, usually I have to take my best guess at the artist and listen to all the songs I have until I find the right one. Talk about inefficient! So I had the idea of simply remembering a line from the song, which, as a singer, I am pretty good at. Then I can look it up in a lyrics DB and find the song. That works OK, but I decided it was time to brush up on the old code skills (sadly, as a Program Manager, I don't get very many opportunities to actually chug out code) and make a little utility program to cross-reference the lyrics search results with an iTunes library search and return only the songs that were actually in my library.

The resulting program took me one evening, including figuring out how to query my lyrics DB of choice, LetsSingIt.com, scrape the data from the results, and cross-reference with iTunes. Yup, right now I just do some ugly HTML scraping to get the results. If anyone knows of a Lyrics DB that offers a web service frontend that I can tie into, please let me know. The scraping code is very bad, and kind of limited right now. For example, if LetsSingIt only returns one result, it jumps directly to that lyrics page instead of showing a page of results. In this case, my scraping code won't work. I'm working on this, but I'd much prefer to find a lyrics DB web service.

I stuff the results of the artist, song title pairs into two ArrayLists. I was going to use a Map, but there's no guarantee that the keys will always be unique if I use either song names or artists. One thing I don't like about C#, though, is that I can't do a multiple object return like I can in Python. I would have liked to say simpy return artists, songs; but C# complained. Oh well. I just stuffed the two ArrayLists into another and upack it on the other side. (Hmmm, I wonder if there's a way I could overload the return keyword and get it to automatically package things up and unpackage them after return, thus simulating Python... hmmm... I must think further on this...)

After getting the artists and songs, I query against the iTunes library for artists first and stuff the results into a temp playlist. Then I search that temp playlist matching on song title. I do things this way because I couldn't figure out a way to search on individual fields within iTunes, and I wanted to search the artist and song title fields explicitly. The final results are stuffed into a "Lyrics Search Results" playlist in iTunes. If a second search is done, the contents of that playlist are overwritten.

And that's it. It's still under development, so no guarantees on anything, of course. You'll need Visual Studio 2005 Beta 2 to open the solution file if you want to recompile, but I don't use any .Net 2.0 stuff, so you could just take the source and recompile it for 1.1 if you wanted. Or just use the .exe file in the Debug/Bin directory directly.

And finally, download the zipped files here.
Suggested Browser: Mozilla Firefox
Theme and layout by Tyler Butler, original CSS classes from Axonz.com
Banner image from "Waiting for the World to Turn," by hermik.
Icons from: