Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Winamp Playlist Queuing via httpQ Interaction

by All_Star25 (Monk)
on Dec 04, 2004 at 01:07 UTC ( #412323=sourcecode: print w/replies, xml ) Need Help??
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 (Curate) on Dec 07, 2004 at 19:33 UTC
    This is even more fun when you install httpq on your friends winamp and don't tell them :-) Hours of entertainment. I worked with a guy who played his music too loud and would also start playing something then leave the office with it running. In this case, everyone *but* the winamp owner had the password :-)

    Cheers
      Heh.... you just made me think of something evil on the fly...
      while(){ while($volume<=255) { get("http://localhost:4800/setvolume?p=pass&level=$volume"); $volume++; } while($volume>=0) { get("http://localhost:4800/setvolume?p=pass&level=$volume"); $volume--; } }
      If you tried that on him, he wouldn't know what to do.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://412323]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2021-01-24 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?