The RIAA/MPAA etc can ruin your life with an expensive, years-long lawsuit whether you are found guilty in the end or not.
If you really want to make it, make it for fun and release it anonymously.
Historical context:
Napster: http://en.wikipedia.org/wiki/Napster#Lawsuit
Legal discussion: http://www.lexology.com/library/detail.aspx?g=c71fa5d9-8380-...
(I am not a lawyer! Get legal advice if you are worried!)
With that being said, they made 1M+ from it and didn't get caught. Your results may vary.
Unhelpful, I know, but it seems like you have legitimate cause for concern, especially if you're located in the US, and HN isn't a source for legal advice regardless of the quality of commenters on the site. This is doubly true since the complexity of your question is likely far greater than you might anticipate, as is often the case with legal concerns, and likely not easily addressed here.
So basically, if you're seriously concerned about legality: consult with an attorney. If you can't, or don't want to, spend the money to do so: don't write the library, or at a minimum don't publically distribute it. And if course, none if this is to be construed as legal advise, yada-yada, etc.