Hacking the playlist

Now playing: Bruce Springsteen / Lost in the flood

I've amassed a, well, massive amount of recorded music over the years. Lately, I've been methodically encoding it all to computer-readable formats, so that I now have a 20 gigabyte disk partition full of .mp3 and .ogg files. I've got no time to assemble playlists. What I want is to have a program to which I can say, "Go look in /media/music, and shuffle the lot."

Now playing: The Beatles / Mr. Moonlight (alt version from Anthology 1)

For the past year or so, I've been using the open source program gqmpeg for this purpose. There were two minor annoyances I found with this setup. First, it took forever to load up that 20 gig into its playlist. Second, I was tied to my X Windows session, because the player is tied to its GUI frontend. I wanted the player to manage the playlist invisibly. If I want to see what's going on, I'll ask the playlist manager.

Now playing: Original cast of 'Take Me Along' / We're home

So, I went on a search for a new playlist manager, and found moosic. Now, this does exactly what I want. It separates the playlist manager functionality from the user interface, and its default user interface is command-line! Outstanding.

Now playing: Leon Redbone / She's my gal

Naturally, I couldn't leave well enough alone. The one weakness I saw with moosic is when I asked it what the currently playing song was, it would reply with the full filename. Well, I add nice Artist, Title and Album tags to my .oggs, so I want to see them. So, it's time for a Perl Hack.

#! /usr/bin/env perl -w

use Audio::File;
use Audio::Moosic;

my $moo = Audio::Moosic::Unix->new();

my $fspec = $moo->current;
my $af = Audio::File->new($fspec);

my $artist = $af->tag->artist() || "";
my $title = $af->tag->title() || "";
my $album = $af->tag->album() || "";

print "$artist\n$title\n$album\n";

Now, of course, if you want constant display, a nice shell script will take care of that.

#! /bin/sh

while true
 playing=`perl ./main.pl`
 if [ ! "$playing" = "$onscreen" ]
     perl ./main.pl
 sleep 10

By the way, the reason I separated this into the perl and shell portions (other than the fact that this is the Unix Way) is that eventually I'm going to pipe the output of the perl script into osd_cat, which does overlaid text.

Now playing: Clannad / Dheanainn sugradh

Eventually, this is going to lead to my extremely local radio station (only within the walls of the house), but that can wait until next post.

Tags: , , ,

No comments: