Winamp Script Rv0.2
Dynamic Image Version
update.php
<?php
$password = testpass;
if (!$_GET[passwd]){ print "NO PASSWORD ";}
if (!$_GET[song]){ print "NO SONG ";}
if ($_GET[passwd] == $password) {
$fp=fopen("song.txt","w");
$song = stripslashes($_GET[song]);
fwrite($fp, $song);
fclose($fp);
} else {
print "password error ";
}
?>
img.php
<?php
$last_update = date ("U", filemtime('song.txt'));
if ($last_update < time()-3600) {
$txtsong = "Not Listening Right Now"; }
else {
$handle = fopen ("song.txt", "r");
while (!feof ($handle)) {
$txtsong = fgets($handle, 4096);
}
}
$font = 2;
$imgw = ImageFontWidth($font) * strlen($txtsong) + (10* ImageFontWidth($font));
if (strlen($txtsong) > 45) {
$txtsong = substr($txtsong, 0, 43)."..";
$imgw = ImageFontWidth($font) * strlen($txtsong) + (10* ImageFontWidth($font));
}
$imgb = ($imgw -1);
Header("Content-Type: image/png");
$im = ImageCreate($imgw, 15);
$bgc = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
ImageFill($im, 0, 0, $bgc);
ImageString($im, $font, 3, 0, "Winamp : $txtsong", $black);
ImageLine($im, 0, 0, 0, 14, $black);
ImageLine($im, 0, 0, $imgb, 0, $black);
ImageLine($im, $imgb, 0, $imgb, 14, $black);
ImageLine($im, 0, 14, $imgb, 14, $black);
Imagepng($im);
?>
Usage
Create song.txt on your server in the same directory as these files.Next, get and install the DoSomething plugin for winamp.
Start Winamp. Go into Options->Preferences->Plug-ins->General Purpose.
Click on DoSomething Plugin.
Click the Configure button.
Of the six checkboxes at the top, check only the Enable ID3 Info Gathering checkbox. Uncheck all of the other five checkboxes.
Under the Actions drop-down box, click Submit a URL. In the URL textbox, cut and paste the following URL:
http://host/folder/update.php?song=%%URL_CURRENTSONG%%&passwd=testpass
(remove the obvious spaces, forum kept truncating the url, grr)
Click the Add --> button at the bottom right. Click the Ok button at the top right.
and all should be well.
Once you have submitted a song, you can either include song.txt into a php page, or link to img.php to display an image on your site or a forum.
Create PNG Version
(aka Spammers-paradise compatable ver :P)up-png.php
<?php
//config
$password = testpass;
//update song
if (!$_GET[passwd]){ print "NO PASSWORD ";}
if (!$_GET[song]){ print "NO SONG ";}
if ($_GET[passwd] == $password) {
$fp=fopen("song.txt","w");
fwrite($fp, $_GET[song]);
fclose($fp);
$font = 2;
$imgw = ImageFontWidth($font) * strlen($_GET[song]) + (10* ImageFontWidth($font));
if (strlen($_GET[song]) > 45) {
$_GET[song] = substr($_GET[song], 0, 43)."..";
$imgw = ImageFontWidth($font) * strlen($_GET[song]) + (10* ImageFontWidth($font));
}
$imgb = ($imgw -1);
$im = ImageCreate($imgw, 15);
$bgc = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
ImageFill($im, 0, 0, $bgc);
ImageString($im, $font, 3, 0, "Winamp : $_GET[song]", $black);
ImageLine($im, 0, 0, 0, 14, $black);
ImageLine($im, 0, 0, $imgb, 0, $black);
ImageLine($im, $imgb, 0, $imgb, 14, $black);
ImageLine($im, 0, 14, $imgb, 14, $black);
Imagepng($im, "song.png");
} else {
print "password error ";
}
?>
Usage
Get and install the DoSomething plugin for winamp.
Start Winamp. Go into Options->Preferences->Plug-ins->General Purpose. Click on DoSomething Plugin. Click the Configure button.
Of the six checkboxes at the top, check only the Enable ID3 Info Gathering checkbox. Uncheck all of the other five checkboxes.
Under the Actions drop-down box, click Submit a URL. In the URL textbox, cut and paste the following URL:
http://host/folder/up-png.php?song=%%URL_CURRENTSONG%%&passwd=testpass
(remove the obvious spaces, forum kept truncating the url, grr)
Click the Add --> button at the bottom right. Click the Ok button at the top right.
and all should be well.
You can now link to http://host/folder/song.png as an image and the song will be displayed.
Note: DoSomething is available from oddsock.org/tools/dosomething/
Note #2: The script is not restriced to Winamp alone, any media player which can submit text including the track name to a URL can be used. I have been informed this is posible with both Windows Media player via a plug-in, and iTunes via AppleScript, currently you'll need to find this information yourself though.
RSS
Secsual./