Author Topic: [PERL] Xmms Playlist to HTML!  (Read 4260 times)

0 Members and 1 Guest are viewing this topic.

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
[PERL] Xmms Playlist to HTML!
« on: February 26, 2006, 12:21:42 pm »
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

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. 

Offline Ergot

  • 吴立峰 ^_^ !
  • x86
  • Hero Member
  • *****
  • Posts: 3724
  • I steal bandwidth. p_o
    • View Profile
Re: [PERL] Xmms Playlist to HTML!
« Reply #1 on: February 26, 2006, 02:27:04 pm »
Very nice!
Who gives a damn? I fuck sheep all the time.
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

Offline Quik

  • Webmaster Guy
  • x86
  • Hero Member
  • *****
  • Posts: 3262
  • \x51 \x75 \x69 \x6B \x5B \x78 \x38 \x36 \x5D
    • View Profile
Re: [PERL] Xmms Playlist to HTML!
« Reply #2 on: February 26, 2006, 02:33:36 pm »
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

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [PERL] Xmms Playlist to HTML!
« Reply #3 on: February 26, 2006, 02:46:21 pm »
Codes made me regurgitate upon my keyboard in a festive manner.

Hahaha.  <3 Quik.

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: [PERL] Xmms Playlist to HTML!
« Reply #4 on: February 26, 2006, 02:59:33 pm »
I don't feel like tidying it up. So sue me. Here you go, x86-cat-playlist.pl!

Code: [Select]
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

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. 

Offline Quik

  • Webmaster Guy
  • x86
  • Hero Member
  • *****
  • Posts: 3262
  • \x51 \x75 \x69 \x6B \x5B \x78 \x38 \x36 \x5D
    • View Profile
Re: [PERL] Xmms Playlist to HTML!
« Reply #5 on: February 26, 2006, 03:09:43 pm »
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

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: [PERL] Xmms Playlist to HTML!
« Reply #6 on: February 26, 2006, 03:19:37 pm »
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

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.