Parenting, Heavy Metal, and Python

_DSC0885

TRUE STORY FOLLOWS:

I went home for the first time in almost 4 months since my wife and I are currently located in two different parts of the country. During that time, both of my daughters had gotten almost 4 months older. No lie. The older one, Alofatunoa, initials ACL (like an Access Control List, get it?), doesn’t yet know how to speak English, BUT she does know how to operate an iPhone. This is where the story starts to get murky…

5fdp

You see, I’m a bit of a connoisseur when it comes to music, so I prefer bands like 5 Finger Death Punch, Sevendust, Emmure, Killswitch Engage, Amon Amarth, Dethklok, and the like, and so these bands are the ones that also reside on my iPhone. And despite whatever attempts I made, my oldest daughter would repeatedly seek out, locate, and operate my iPhone and turn on my music and maximize the volume (and then start dancing, which is really cute). But alas, some of these bands tend to be potty mouths from time to time which we’d rather not bestow upon our children.

So I had a few options:

1. Write a letter to the self-annointed “Ambassadors of Hate” and request that their next album in the coming years not contain so much dirty language and then wait a couple years for the next album.

2. Stop listening to these bands and switch over to Justin Bieber.

3. Write a python script that interfaces with an existing API that would return the lyrics of a song given its artist and title and then isolate which songs contained any curse words, and then create a new music library from only the clean songs.

I went with choice number 3 and put together a script which interfaced with MusixMatch.com, and the resulting script can be found on Github here.

The results were for the most part accurate. The problem is that MusixMatch does not necessarily have every song known to man in their database, so in the case that they did not have the song I wanted with its corresponding lyrics, I assumed that the song contained curse words and therefore could not be safely migrated to the clean music library. I also used a trial API key, and therefore I only get something like 50% of the lyrics, but this seemed to work well enough for my needs in this case.

If you have any desire to run the script yourself, you can get an API key from musixmatch here.