Added REMOVEGRP for removing groups of songs.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@596 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
#
|
#
|
||||||
# $Id: musicd,v 1.12 2002/02/11 18:25:44 mdb Exp $
|
# $Id: musicd,v 1.13 2002/02/22 08:36:28 mdb Exp $
|
||||||
#
|
#
|
||||||
# MP3 audio server. Manages playlists of mp3 files that live on a local
|
# MP3 audio server. Manages playlists of mp3 files that live on a local
|
||||||
# filesystem. The playlists can be manipulated by connecting to the server
|
# filesystem. The playlists can be manipulated by connecting to the server
|
||||||
@@ -102,12 +102,12 @@ sub handle_client
|
|||||||
my $path = $3;
|
my $path = $3;
|
||||||
|
|
||||||
# make sure the file they provided exists and is readable
|
# make sure the file they provided exists and is readable
|
||||||
if (-r $path) {
|
# if (-r $path) {
|
||||||
push @playlist, [ $eid, $sid, $path ];
|
push @playlist, [ $eid, $sid, $path ];
|
||||||
print $cfh "200 Appended '$eid:$sid:$path' to playlist.\n";
|
print $cfh "200 Appended '$eid:$sid:$path' to playlist.\n";
|
||||||
} else {
|
# } else {
|
||||||
print $cfh "404 Unable to read playlist candidate: '$path'\n";
|
# print $cfh "404 Unable to read playlist candidate: '$path'\n";
|
||||||
}
|
# }
|
||||||
|
|
||||||
# if we're not playing a song, start playing now that we have a
|
# if we're not playing a song, start playing now that we have a
|
||||||
# playlist with songs in it
|
# playlist with songs in it
|
||||||
@@ -115,6 +115,47 @@ sub handle_client
|
|||||||
play_next_tune();
|
play_next_tune();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} elsif ($input =~ m/^REMOVEGRP (\d+) (\d+)/) {
|
||||||
|
my $sid = $1;
|
||||||
|
my $count = $2;
|
||||||
|
|
||||||
|
# remove the requested number of songs from the playlist starting
|
||||||
|
# with the first song that matches the specified songid
|
||||||
|
my $sidx = -1;
|
||||||
|
my $i;
|
||||||
|
my $yanked = 0;
|
||||||
|
|
||||||
|
for ($i = 0; $i < @playlist; $i++) {
|
||||||
|
if ($playlist[$i]->[1] == $sid) {
|
||||||
|
$sidx = $i;
|
||||||
|
splice(@playlist, $i, $count);
|
||||||
|
# adjust the playing index if necessary
|
||||||
|
if ($index < $i) {
|
||||||
|
# nothing to do here
|
||||||
|
} elsif ($index >= $i && $index < $i + $count) {
|
||||||
|
# we removed the playing tune
|
||||||
|
$yanked = 1;
|
||||||
|
$index = $i-1;
|
||||||
|
} else {
|
||||||
|
# we removed tunes from before the currently playing
|
||||||
|
# tune so we adjust index
|
||||||
|
$index -= $count;
|
||||||
|
}
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# now check to see if we've removed the playing tune
|
||||||
|
if ($yanked) {
|
||||||
|
play_next_tune();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sidx >= 0) {
|
||||||
|
print $cfh "200 Removed $count entries from position $sidx.\n";
|
||||||
|
} else {
|
||||||
|
print $cfh "404 Unable to locate $sid in playlist.\n";
|
||||||
|
}
|
||||||
|
|
||||||
} elsif ($input =~ m/^REMOVE (\d+)/) {
|
} elsif ($input =~ m/^REMOVE (\d+)/) {
|
||||||
my $sid = $1;
|
my $sid = $1;
|
||||||
|
|
||||||
@@ -138,7 +179,7 @@ sub handle_client
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($sidx >= 0) {
|
if ($sidx >= 0) {
|
||||||
print $cfh "200 Removed $sid from position $i.\n";
|
print $cfh "200 Removed $sid from position $sidx.\n";
|
||||||
} else {
|
} else {
|
||||||
print $cfh "404 Unable to locate $sid in playlist.\n";
|
print $cfh "404 Unable to locate $sid in playlist.\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user