version 1.1, 2006/03/02 23:20:47 |
version 1.4, 2010/03/26 14:21:55 |
|
|
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
|
# $RedRiver: createfulllist.pl,v 1.3 2007/02/08 20:04:03 andrew Exp $ |
######################################################################## |
######################################################################## |
# showall.pl *** Displays all MP3's in all subdirs |
# showall.pl *** Displays all MP3's in all subdirs |
# |
# |
|
|
#my qw/ $basedir %mp3s %dirs $countdir $countmp3 $fulllist /; |
#my qw/ $basedir %mp3s %dirs $countdir $countmp3 $fulllist /; |
|
|
my $basedir = '/home/mp3/Sorted'; |
my $basedir = '/home/mp3/Sorted'; |
my $subdir = $ENV{'QUERY_STRING'}; |
|
my $playlist = '/var/www/mp3/playlist/playlist.lst'; |
|
my $fulllist = '/var/www/mp3/playlist/fulllist.lst'; |
|
my $newlist = '/var/www/mp3/playlist/newlist.lst'; |
|
|
|
my $countdir = 0; |
my $countdir = 0; |
my $countmp3 = 0; |
my $countmp3 = 0; |
|
|
# *** MAIN *** |
# *** MAIN *** |
####################################################################### |
####################################################################### |
|
|
if ($subdir) { |
my $query_string = $ENV{'QUERY_STRING'} || q{}; |
$subdir =~ s/%(..)/pack("c",hex($1))/ge; |
my ($prefix, $subdir) = split /\&/, $query_string; |
|
if ($subdir) { |
|
$subdir =~ s/%(..)/pack("c",hex($1))/ge; |
} else { |
} else { |
$subdir =''; |
$subdir =''; |
} |
} |
|
|
|
if ($prefix) { |
|
$prefix =~ s/%(..)/pack("c",hex($1))/ge; |
|
} else { |
|
$prefix =''; |
|
} |
|
|
|
my $playlist = '/var/www/mp3/playlist/' . $prefix . 'playlist.lst'; |
|
my $fulllist = '/var/www/mp3/playlist/' . $prefix . 'fulllist.lst'; |
|
my $newlist = '/var/www/mp3/playlist/' . $prefix . 'newlist.lst'; |
|
|
#$basedir = $basedir . "/" . $subdir; |
#$basedir = $basedir . "/" . $subdir; |
|
|
print "Content-Type: text/html\n\n"; |
print "Content-Type: text/html\n\n"; |
|
|
# my $count; |
# my $count; |
# my @sorted = sort { lc($dirs{$a}) cmp lc($dirs{$b}) } (keys %dirs); |
# my @sorted = sort { lc($dirs{$a}) cmp lc($dirs{$b}) } (keys %dirs); |
# foreach my $dir (@sorted) { |
# foreach my $dir (@sorted) { |
# print "<a href=\"showfiles.pl\?" . EncodeURL("$dir/$dirs{$dir}") . "\">$dirs{$dir}</a><br>"; |
# print "<a href=\"showfiles.pl\?" . EncodeURL($prefix) . '&' . EncodeURL("$dir/$dirs{$dir}") . "\">$dirs{$dir}</a><br>"; |
# $count++; |
# $count++; |
# } |
# } |
# print "Total dirs displayed: $count<p>\n"; |
# print "Total dirs displayed: $count<p>\n"; |
|
|
# my $count; |
# my $count; |
# foreach my $mp3dir (sort keys %mp3s) { |
# foreach my $mp3dir (sort keys %mp3s) { |
# foreach $mp3 (@{ $mp3s{$mp3dir} }) { |
# foreach $mp3 (@{ $mp3s{$mp3dir} }) { |
# print "\t<li>Song: <a href=\"$addurl\?" . EncodeURL("$mp3dir/$mp3") . "\" target=\"bottom\">$mp3</a></li>\n"; |
# print "\t<li>Song: <a href=\"$addurl\?" . EncodeURL($prefix) . '&' . EncodeURL("$mp3dir/$mp3") . "\" target=\"bottom\">$mp3</a></li>\n"; |
# $count++; |
# $count++; |
# } |
# } |
# } |
# } |
|
|
print "<ul>\n"; |
print "<ul>\n"; |
foreach my $directory (@directories) { |
foreach my $directory (@directories) { |
# $dirs{"$DIR/$directory"} = $directory; |
# $dirs{"$DIR/$directory"} = $directory; |
print "<li><a href=\"showfiles.pl\?" . EncodeURL("$DIR/$directory") . "\">$directory</a>"; |
print "<li><a href=\"showfiles.pl\?" . EncodeURL($prefix) . '&' . EncodeURL("$DIR/$directory") . "\">$directory</a>"; |
print " - <font size=\"-1\"><a href=\"" . "showall.pl" . "\?" . EncodeURL("$DIR/$directory") . "\">All</a></font></li>"; |
print " - <font size=\"-1\"><a href=\"" . "showall.pl" . "\?" . EncodeURL($prefix) . '&' . EncodeURL("$DIR/$directory") . "\">All</a></font></li>"; |
|
|
$countdir++; |
$countdir++; |
my @curdir = GetDirListing("$DIR/$directory"); |
my @curdir = GetDirListing("$DIR/$directory"); |
|
|
|
|
|
|
# push @dirs, @curdir; |
# push @dirs, @curdir; |
# print "<a href=\"showfiles.pl\?" . EncodeURL("$DIR/$directory") . "\">$directory</a><br>"; |
# print "<a href=\"showfiles.pl\?" . EncodeURL($prefix) . '&' . EncodeURL("$DIR/$directory") . "\">$directory</a><br>"; |
} |
} |
opendir DIR, "$basedir/$DIR" or bail("Unable to opendir DIR: $!"); |
opendir DIR, "$basedir/$DIR" or bail("Unable to opendir DIR: $!"); |
my @temp = sort grep /\.(mp3|ogg)$/i, readdir(DIR); |
my @temp = sort grep /\.(mp3|ogg)$/i, readdir(DIR); |
# $mp3s{"$DIR/$directory"} = [ @temp ]; |
# $mp3s{"$DIR/$directory"} = [ @temp ]; |
print "<ul>\n"; |
print "<ul>\n"; |
foreach my $mp3 (@temp) { |
foreach my $mp3 (@temp) { |
# print "\t<li>Song: <a href=\"$addurl\?" . EncodeURL("$DIR/$mp3") . "\" target=\"bottom\">$mp3</a></li><br>\n"; |
# print "\t<li>Song: <a href=\"$addurl\?" . EncodeURL($prefix) . '&' . EncodeURL("$DIR/$mp3") . "\" target=\"bottom\">$mp3</a></li><br>\n"; |
print "\t<li>"; |
print "\t<li>"; |
AddSong("$DIR/$mp3", "$fulllist.new"); |
AddSong("$DIR/$mp3", "$fulllist.new"); |
print "</li>\n"; |
print "</li>\n"; |
|
|
for ($j=0;$j<=$i;$j++) { |
for ($j=0;$j<=$i;$j++) { |
$url = "$url/$filename[$j]"; |
$url = "$url/$filename[$j]"; |
} |
} |
print "/<a href=\"showfiles.pl\?" . EncodeURL($url) . "\">$filename[$i]</a>"; |
print "/<a href=\"showfiles.pl\?" . EncodeURL($prefix) . '&' . EncodeURL($url) . "\">$filename[$i]</a>"; |
|
|
} |
} |
} else { |
} else { |
|
|
# $filename =~ s/%(..)/pack("c",hex($1))/ge; |
# $filename =~ s/%(..)/pack("c",hex($1))/ge; |
chomp $filename; |
chomp $filename; |
print "Added $filename<br>\n"; |
print "Added $filename<br>\n"; |
open PLAYLIST, ">>$list" or bail("unable to open PLAYLIST: $!"); |
open PLAYLIST, ">>$list" or bail("unable to open PLAYLIST '$list': $!"); |
print PLAYLIST "$filename\n"; |
print PLAYLIST "$filename\n"; |
close PLAYLIST or bail("unable to close PLAYLIST: $!"); |
close PLAYLIST or bail("unable to close PLAYLIST: $!"); |
} else { |
} else { |