Tuesday, January 31, 2012

Ampache woes

So at some point something went horribly wrong with my ampache setup. I decided to try the ampache script that renamed files using the tag information. This seemed like a good idea, because my files weren't all named or organized in a consistent way. After a couple attempts, I noticed that all my songs in ampache were by an artist who's name started with the directory path to the file. Great. At the time I was pretty sure I had messed up the mp3 tag data because after rebuilding the catalog in ampache, nothing changed. Artist name was still the directory name (/mnt/usb_mmedia/music/itunes/...). I tried to fix things a couple times but I seemed to make it worse.

Fast forward maybe a year to the past week. I decide it's time to go fix my library. I wanted to start by fixing the MP3 tags, so I downloaded some utils and started to work. But I couldn't find anything wrong with the mp3 tags. The artist was correct here. I also noticed when playing a song through ampache that the artist name seemed to come out correctly there as well. So what the heck is going on?

I start putting print statements in the ampache code to see what it is doing when I verify the catalog. I eventually discover that it is not looking up mp3 tags when building the catalog and instead trying to generate the information from the filename. This is happening because I no longer had an entry in the ampache config file for mp3 tag processing order. I put that back in and everything goes back to normal in Apache.

So why was I missing that config line? It goes back to another problem I had with ampache where catalog verification/creation would hang at some point as the mp3id library would get stuck and chew up memory. This was a known issue with ampache which happened on some files who have corrupted tag information. It was quite hard at the time to identify which files these were and besides, I didn't know how to fix them. The only option was to stop ampache from reading the mp3 tag information by removing the tag order config key. It worked find until I tried to verify the catalog.

This is exactly why I do not like to employ hack work arounds, they always come back to bite you later.

The other stupid thing about all this is that ampache was using a deprecated php method (eregi) and would spit out errors during catalog verification. The response from the ampache devleoper was to downgrade php to an older version or use the alpha version of ampache. Really? What kind of choice is that? Have you ever tried to downgrade something in linux? Remember these systems are a tight-nit web of dependencies. You can't just go around back-revving major packages. I don't know how the stable version of ampache was even going to work on recent distribution releases. I had to replace all the calls in the ampache source code with the proper methods, then everything worked. Thanks open source!

No comments:

Post a Comment