Creative uses for symlinks in Apache::MP3

Posted:

Lincoln Stein’s remarkably useful module Apache::MP3is respects symbolic links. That is, if you symlink an MP3 file Apache::MP3 will server it like any other MP3 file (as long as you Apache is allowed to FollowSymlinks in that directory). This small detail allows for some darn useful tricks to help you organize and expand your MP3 collection.

Problem 1: Collecting stray singles under one artist’s folder.

If you’re like me, you have several single MP3’s that “fell off the back of an internet truck.” You probably have ripped your own CDs too. While you could simply move the singles into the artist folder (easy to do), you can also put a symlink to single there. A more compelling example for this case is the compliation CD. You don’t want to move the MP3 files from the collection into the associated artist folder and you don’t want to copy the MP3 (wastes disk disk). Instead, consider making a symlink.

Problem 2: Creating permanent playlists.

Create your own radio station! Tired of not fitting into your local radio’s format? Make your own! Create a folder called The 80s. Next, find all the good 80s singles in your collection and create symlinks to them. Heck, you can even record (or programatically generate) your own fake ads and put those in mix too! Image the possiblities of Markov chains, speech synthesis and some simple mixing. That’s fake advertisement and that will make you pretend reach for your imaginary wallet. Throw in some RSS feeds and you got news too.

Problem 3: Spanning an MP3 collection across two disks.

Your MP3 collection has gotten too large so you need a add a second disk. Perhaps you need to press another machine into the fray. In either case, you can symlink to the mount point of the disk from the MP3 directory.
Perhaps you can call the symlink “more”. If that leaves you unsatisfied, you can write a simple shell script that creates symlinks to the individual directories on the other disk. One wrinkle is that you will have to handle merging artist folders. For instance, let’s say in you original MP3 collection, you’ve ripped a few Prince albums. On the new disk, you’ve ripped his Sign O The Times epic. Now, you want the script to symlink the album under your original Prince folder. This I leave as a not-too-difficult excerise for the reader.

UPDATE: Corrected factual error about symlinks versus hard links. I must lay of the crack.

[Original use.perl.org post and comments.]