News:

So the widespread use of emojis these days kinda makes forum smileys pointless, yeah?

Main Menu

[PERL] Xmms Playlist to HTML!

Started by Newby, February 26, 2006, 12:21:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Newby

Yes. I got so bored this morning, that I decided to turn the XMMS playlist into the Winamp Generated Playlist format.

See the example here!

I'll release the code once I tidy it up. :)
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Ergot

Quote from: Newby on February 26, 2006, 12:16:58 AM
Who gives a damn? I fuck sheep all the time.
Quote from: rabbit on December 11, 2005, 01:05:35 PM
And yes, male both ends.  There are a couple lesbians that need a two-ended dildo...My router just refuses to wear a strap-on.
(05:55:03) JoE ThE oDD: omfg good job i got a boner thinkin bout them chinese bitches
(17:54:15) Sidoh: I love cosmetology

Quik

Codes made me regurgitate upon my keyboard in a festive manner.
Quote[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Sidoh

Quote from: Quik on February 26, 2006, 02:33:36 PM
Codes made me regurgitate upon my keyboard in a festive manner.

Hahaha.  <3 Quik.

Newby

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()
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Quik

What a mess! Throw some goddamn linebreaks in there or something, it's a bitch to read!
Quote[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Newby

Too lazy. Must mimic the Winamp playlist exactly.
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT.