#!/usr/bin/perl -w # # Report on the currently playing MP3 track use strict; print "Content-type: text/html\n"; print "Refresh: 60; URL=/cgi-bin/playinfo\n\n"; my $pid = `ps ax|grep madplay|grep -v grep|awk '{print \$1}'`; chomp $pid; if ($pid == 0) { print "No track currently playing.\n"; exit; } my $file = `cat /proc/$pid/cmdline|cut -c12-`; chomp $file; my ($dir, $name) = ($file =~ q#^(.*)/(.*?)$#); # Try to retrieve ID3 tag $name = `mp3info -p '%t' "$file" 2>/dev/null` || $name; chomp $name; # Tidy up the directory name $dir =~ s#/root/mp3/##g; $dir =~ s#/# / #g; print "
Now playing: $dir / $name
\n"; print "";