scriptygoddess

17 Jun, 2002

Display recent WinAmp playlist

Posted by: amy In: Scripts

Some of you may have played around with DoSomething, a WinAmp plugin that allows you to generate songlists. While originally intended for Shoutcasters, I fell in love with this plugin over a year ago, and have been using it ever since to generate automatically-updated lists of the songs that have recently played in WinAmp.

Requirements: WinAmp, DoSomething plugin, PHP, and a FTP account.

(Setting up DoSomething is a bit beyond the scope of this post, and there's a tutorial here.)

This code takes specially-formatted output from the DoSomething plugin and generates a nicely-formatted list of recent songs. The artists' names are linked to allmusic.com in the appropriate format, and if an album title is available, it is made available to the reader in the form of an <acronym> tag around the title of the song.

This particular update changes the code to a function—in this case, show_playlist()—something I should have done months ago. I've also set up the function so that it has the following three parameters:

show_playlist($number, $title_separator, $line_separator);

$number tells the function how many songs to display. $title_separator should be encased in quotation marks, and tells the function what characters to place between the artist's name and the song title. (Common ones will be " – " or "<br>".) $line_separator does the same thing, except between songlist entries. (I generally use "<br><br>" or "<br>".)

Thus, an end result might look like this:

show_playlist(3, " – ", "<br>");

and display output in the following format:

artist of song – title of song (line break)
artist of song – title of song (line break)
artist of song – title of song (line break)

This is a major rewrite of the previous script, with a lot of error-correction added (as well as flexible support for album titles). You can download the .zip file here, or read my full entry about the files. This script is currently in usage at domesticat.net, if you want to get an idea of what the output looks like.

17 Responses to "Display recent WinAmp playlist"

1 | Pete

June 17th, 2002 at 11:26 pm

Avatar

I discovered that this plugin doesn't work in Windows XP. I was quite not happy with that. I'm going to try upgrading winamp, if I haven't already… but this always died on the second time the script ran. Killed winamp too. Is anyone else having this problem?

2 | Amy

June 18th, 2002 at 12:32 am

Avatar

Oddsock runs a forum devoted to the code he writes; you'd be best off directing your questions there. It's possible that this problem has been covered (and perhaps solved) there.

3 | Jennifer

June 18th, 2002 at 8:18 am

Avatar

Cool! Thanks for posting this Amy! 😀

4 | Danielle

June 27th, 2002 at 3:18 pm

Avatar

I know that this is propably a really stupid question and I apologize in advance if I'm wasting your time. I read the Do Something description and checked the forums but I have no idea how to get any further than generating a playlist on my C drive as an html file. Am I supposed to have that in my cgi bin as a text file? Any help on this is really appreiated.

5 | Will

September 22nd, 2002 at 9:32 am

Avatar

After reading this and looking at an example or two, I had a look at DoSomething and ended up writing something similar. My script displays the song I'm currently listening to by using DoSomething's 'Submit to URL' function. This is very useful for those of us who don't have FTP access. If anyone would like to have a look at the PHP side of it, feel free to contact me. :)

6 | Will

September 22nd, 2002 at 9:34 am

Avatar

Oh, and another thing… I've noticed that the current version of DoSomething (2.11) doesn't seem to work with Winamp 3.

7 | Garrett

October 19th, 2002 at 12:19 am

Avatar

In case anyone is still looking for a simple, easy to use alternative to DoSomething, please check out my Winamp2 plugin, CurrentlyHearing. You can find it on my website, ManiacalRage, at this location: http://www.maniacalrage.net/index.php?PG=6

8 | jess

November 10th, 2002 at 5:56 pm

Avatar

Apparently I have something set up wrong as the file generated (and subsequently uploaded) is nothing but
||
||
|| (for 10 rows)

any ideas as to what is causing this to occur?

thanks

9 | Amy

November 10th, 2002 at 6:44 pm

Avatar

Hmm. Have you checked to make sure that the files you're playing have ID3 tags? That would be my guess.

10 | jess

November 11th, 2002 at 11:39 pm

Avatar

Thanks amy! After your idea I delved the actual files and realized that I was actually getting output when I played .mp3 files, however most of my music is in .wma, which for some apparent reason does not generate output.

So if anyone has any ideas on a way to get output using .wmas, lemme know.

11 | Beth

February 13th, 2003 at 6:37 am

Avatar

I got everything working and such, but for some reason it doesn't upload to my server. Now, I can upload the local file to update it and there are no errors.

I have the mp3s-out.php going to my main domain public file. I am wondering if I am supposted to put the server directory (/home/dysis/public_html/) or the domain directory (simply, "/"). also how do i write the ftp address? do i put ftp in front like so, "ftp://ftp.dysis.nu" or do i just put "ftp.dysis.nu".

your help is greatly appriciated. thank you.

12 | iced glare

April 6th, 2003 at 10:08 am

Avatar

While trying to use this script I get this error as the results



/* –
This needs to go in the head of your document. –
*/ –


the sentence is also hyperlinked.

my mp3s-out.php files looks like this

<HTML><HEAD>
<?php
/*
This needs to go in the head of your document.
*/

function show_playlist($number, $title_separator, $line_separator) {
# Change this to point to the full server path to your mp3s-out.txt file

$playlist = "/home/mehere/goesthere/more/mp3s-out.php";
$line = file($playlist);
if (!$line) die( "Can't access playlist at this time." );
$total_length = count($line);
$i=0;

while (($i+1) <= $number) {
if (($i+1) > $total_length) break;

$this_song = explode( '||', $line[$i] );

# if nothing, I don't want to print blanks
if ($this_song && ($line[$i] != "||||\n") ) {

# get the variables
$artist = $this_song[0];
$title = $this_song[1];
$album = trim($this_song[2]);

# clean up for the mouseover
$artist_jscript_safe = str_replace("'", "\'", $artist);

# clean up for allmusic.com
$artist_allmusic = str_replace(" ", "|", $artist);
$artist_allmusic = str_replace(",", "", $artist_allmusic);

# now let's print out the results

echo "<a href=\"http://www.allmusic.com/cg/amg.dll?p=amg&sql=1" . $artist_allmusic . "\" \n";
echo "onMouseOver=\"window.status='See " . $artist_jscript_safe . "\'s entry at allmusic.com';return true\" \n";
echo "onMouseOut=\"window.status=";return true\" \n";
echo "title=\"See " . $artist . "'s entry at allmusic.com\" \n";
echo "target=\"_blank\">" . $artist . "</a>" . $title_separator . "\n";

# only print the CD title if it's there
if ($album) {
echo "<acronym title=\"from the album: " . $album . "\">" . $title . "</acronym>" . $line_separator . "\n";
}
else echo $title . $line_separator . "\n";

}
else $number++;

$i++;
}
}
?>

</HEAD>
<BODY>

<!–

Now, to use this…put the above function bit at the top of your document, and make
sure that you've got the $playlist line pointing to your mp3s-out.txt file.

Place the following line where you want your songlist to appear:

<? show_playlist(5, " – ", "<br>"); ?>

That line would display 5 songs in the following format:

artist of song – title of song <line break>
artist of song – title of song <line break>
artist of song – title of song <line break>
artist of song – title of song <line break>
artist of song – title of song <line break>

Get creative with your output, and good luck!

– Amy
–>

<? show_playlist(5, " – ", "<br>"); ?>

Everything is all set up in "dosomething" and I am using winamp 2.9

13 | Amy

April 7th, 2003 at 12:17 am

Avatar

If you don't mind, I'd like to see the URL to the page where you're getting this error, as right now I'm not sure what things would have to happen to cause the error you're describing.

14 | iced glare

April 9th, 2003 at 4:23 am

Avatar

Ok I'll send it you

15 | iced glare

April 23rd, 2003 at 12:53 pm

Avatar

OK I found another way to do it by adding a category and using trackbacks in winamp. thanks though!!

16 | Intruder

April 25th, 2003 at 2:14 pm

Avatar

I cant seem to get any way of putting my song in my site, tried this way, tried the categories way, and still doesnt work! Could anyone email me about this? And I still see no instructions of the use of DoSomthing here…

17 | nugs

October 1st, 2004 at 11:24 pm

Avatar

Ack!! Allmusic.com changed their site! I tried to reverse engineer the way their new search tool works but it's sending data through a dll.

Little help? Anyone? :-(

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements