I don't feel like tidying it up. So sue me. Here you go, x86-cat-playlist.pl!
use Xmms::Remote ();
sub printlist()
{
my $xmms = Xmms::Remote->new;
if ( !$xmms->is_running)
{
print("Xmms isn't running. No can do.");
}
my $playlistlength = $xmms->get_playlist_length();
for ($count=0; $count < $playlistlength; $count++)
{
my $title = $xmms->get_playlist_title($count);
my $songlen = parse_time($xmms->get_playlist_time($count));
print(($count+1).". $title ($songlen)<BR>\n");
}
}
sub main()
{
my $tempxmms = Xmms::Remote->new;
my $length = $tempxmms->get_playlist_length();
my $time = 0;
for ($count=0; $count < $length; $count++)
{
$time = $time + $tempxmms->get_playlist_time($count);
}
my $avgtime = sprintf("%02d:%02d", ((($time/$length)/1000)/60), ((($time/$length)/1000)%60));
my $time2 = sprintf("<font face=\"Arial\" color=\"#FFBF00\">%d</font> hours, <font color=\"#FFBF00\">%d</font> minutes, <font color=\"#FFBF00\">%d</font> seconds", ((($time/1000)/60)/60), ((($time/1000)/60)%60), (($time/1000)%60));
# print("<html>\n<head>\n<title>Xmms Generated Playlist</title>\n</head>\n<body bgcolor=\"#000040\">\n<font face=\"Arial\" color=\"#FFFFFF\">\n<small>\n");
print <<STARTHTML;
<html><head><link rel="stylesheet" href="null"><style TYPE="text/css"><!--BODY { background: #000040; }
.para1 { margin-top: -42px; margin-left: 145px; margin-right: 10px; font-family: "font2, Arial"; font-size: 30px; line-height: 35px; text-align: left; color: #E1E1E1; }
.para2 { margin-top: 15px; margin-left: 15px; margin-right: 50px; font-family: "font1, Arial Black"; font-size: 50px; line-height: 40px; text-align: left; color: #004080; }
--></style><title>XMMS Generated PlayList</title></head><body BGCOLOR="#000080" topmargin="0" leftmargin="0" text="#FFFFFF"><!--TOOLBAR_START--><!--TOOLBAR_EXEMPT-->
<div align="center"><div CLASS="para2" align="center"><p>XMMS</p></div><div CLASS="para1" align="center">
<p>playlist</p></div></div><hr align="left" width="90%" noshade size="1" color="#FFBF00"><div align="right">
<table border="0" cellspacing="0" cellpadding="0" width="98%"><tr><td><small><small><font face="Arial" color="#FFBF00">
$length</font><font color="#409FFF" face="Arial"> tracks in playlist, average track length: </font><font face="Arial" color="#FFBF00">$avgtime</font></small></small><br><small><small><font color="#409FFF" face="Arial">Playlist length: $time2 <BR>
<font color="#409FFF" face="Arial">Right-click <a href="./playlist.html">here</a> to save this HTML file.</font></small></small></td></tr></table></div><blockquote><p><font color="#FFBF00" face="Arial"><big>Playlist files:</big></font><ul><font face="Arial" color="#FFFFFF"><small>
STARTHTML
printlist();
print <<ENDHTML;
</font></ul></blockquote><hr align="left" width="90%" noshade size="1" color="#FFBF00"></body></html>
ENDHTML
}
sub parse_time()
{
my $xmms_time = shift;
my $seconds = $xmms_time / 1000;
my $minutes = $seconds / 60;
$seconds = $seconds % 60;
return sprintf("%d:%02d", $minutes, $seconds);
}
main()