| Category: | CGI Programming |
| Author/Contact Info | All_Star25 |
| Description: | This code takes a filename as a parameter, and attempts to interact with the Winamp httpQ plugin (http://httpq.sf.net/), assumed to be listening on a local port. This is a way to allow remote users to queue music files to play without letting them know the httpQ password (because as far as I know, anyone with the password and connecting from an allowed IP can execute any httpQ command- the commands are either one can use them all or use none of them). Make sure to change the addresses and directory references for it to work. |
#!/usr/bin/perl -wT
use CGI qw(:all);
use LWP::Simple qw(get);
use strict;
print header;
my $song = param('song');
my $directory = "insert_directory_here";
my $historylength = 5;
my $pass = "pass";
my $url = "";
my $result = "";
my $songentry = $directory . $song;
#get the current position of the playing song 0=first song, 1=second s
+ong, etc
$url = "http://localhost:4800/getlistpos?p=$pass";
$result = get($url);
if ( $result > $historylength ) {
my $numbertotrim = ( $result - $historylength );
for ( my $i = 1 ; $i == $numbertotrim ; $i++ ) {
$url = "http://localhost:4800/deletepos?p=$pass&index=0";
$result = get($url);
if ( $result != 1 ) {
$i = $numbertotrim;
}
}
}
# Change the working directory for sanity
$url = "http://localhost:4800/chdir?p=$pass&dir=\"insert_directory_
+here\"";
$result = get($url);
if ( $result == 0 ) {
&htmlsub("There was an error handling your request.");
}
# Load the list
$url = "http://localhost:4800/getplaylistfile?p=$pass&delim=;";
$result = get($url);
if ( $result eq 0 ) {
&htmlsub("There was an error handling your request.");
}
else {
my @songs = split( ';', $result );
my $playlistentry = "";
foreach $playlistentry (@songs) {
if ( $songentry eq $playlistentry ) {
&htmlsub("That song is already in the playlist.");
}
}
}
#queue it up, if there are no precedents
$url = "http://localhost:4800/playfile?p=$pass&file=" . $songentry;
$result = get($url);
if ( $result == 0 ) {
&htmlsub("There was an error handling your request.");
}
else
{ # report success/failure to queue, possibly name the place it is
+queued in?
&htmlsub("The song you requested has been queued.");
}
sub htmlsub { # this is where you format the HTML
print $_[0];
print "<BR>";
exit(0);
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Winamp Playlist Queuing via httpQ Interaction
by elwarren (Priest) on Dec 07, 2004 at 19:33 UTC | |
by All_Star25 (Monk) on Dec 10, 2004 at 00:10 UTC |