Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jjohn (22)

  (email not shown publicly)
AOL IM: taskboy3000 (Add Buddy, Send Message)

Perl hack/Linux buff/OSS junkie.

Journal of jjohn (22)

Tuesday September 23, 2003
06:00 AM

Creative uses for symlinks in Apache::MP3

[ #14850 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Does this exist ? :-p
  • link it again, Sam (Score:3, Insightful)

    by jmm (276) <> on 2003.09.23 8:32 (#24436) Journal
    That's because symlinks, on most systems, don't work across device boundries. You can create hard links though.

    Um, that's backwards for Unix derived systems, which as a class by themselves satisfies the term most systems. (Unix, Linux, BSD, OS X, ...)

    Hard links only work within a single file system (because they are an alternate name for the same i-node, and an i-node is a name that is unique only if you already know what file system it is contained in) while symlinks map one name into another name (which means that they can cross file system boundaries).

  • How about songs that belong to multiple artists? The stellar "Disorder" by Slayer and Ice-T should have symlinks to it from both artists' directories. (The entire album is team-ups like that)

    Maybe you have a directory of guest appearances, where the Eric Clapton guest appearances points at "While My Guitar Gently Weeps" by the Beatles, and the entire The Pros And Cons Of Hitchhiking by Roger Waters.