Done some work on the stable version of GNUMP3d that you may want to use
or add to. The attached diffs do the following:
* Removed a space between #EXTINF: and the seconds count
* Suggested a .m3u filename in the header for playlists so silly
players like XMMS know whats coming
* Tag called $FULLPATH. Full path and filename for sorting etc
* Fixed bug with no paths put into @FOUND in &filesInDir
* Case insensitive sorting on $FULLPATH and others
I am interested in people's opinion on if the recurs.m3u call should
result in files being selected that are NOT matching the viewing
preferences (OGG, MP3 and Movies). Should they be selected or not?
IMO, the options should be changed so that the file types options
reflect what is viewed, and selected. This is just a personal
preference.
Also, how bout custom playlists where not just directories can be
selected? Due to sheer volume of some directories, some thought would
need to be put in about how to go about this. But is this a feature
people want?
Cheers
--- sorting.pm 2005-11-17 08:46:53.000000000 +0800
+++ sorting.pm.new 2005-12-02 21:55:37.000000000 +0800
@@ -136,13 +136,19 @@
{
@SORTED = sort{ return (stat($b))[9] <=> ( stat($a))[9]; } @files;
}
+ elsif ( $format =~ /\$FULLPATH/ )
+ {
+ @SORTED = sort{ print "One: $a\n";
+ print "Two: $b\n";
+ return( uc($a) cmp uc($b) ); } @files;
+ }
else
{
@SORTED = sort{ my $one = getSongDisplay( $a, $format );
my $two = getSongDisplay( $b, $format );
print "One: $one\n";
print "Two: $two\n";
- return( $one cmp $two ); } @files;
+ return( uc($one) cmp uc($two) ); } @files;
}
# Restore the previous format string.
--- files.pm 2005-11-17 08:46:53.000000000 +0800
+++ files.pm.new 2005-12-02 21:51:43.000000000 +0800
@@ -40,6 +40,7 @@
@ISA = qw(Exporter);
@EXPORT = qw( &filesInDir &filesInDirRecursively
+ &filesInDirsOnlyRecursively
&dirsInDir &getSuffix
&isAudio &isPlaylist &isMovie
&readFile &readFileWithExpansion
@@ -129,7 +130,7 @@
if ( -f $dir . "/" . $entry )
{
- push @FOUND, $entry;
+ push @FOUND, $dir . "/" . $entry;
}
}
@@ -171,6 +172,35 @@
#
+# Read all non . files within directories in the given directory recursively.
+#
+# The returned list will be sorted.
+#
+sub filesInDirsOnlyRecursively( $ )
+{
+ my ($dir) = (@_);
+ opendir(DIR, $dir) or warn "Cannot open directory : $dir :$!";
+ my @entries = readdir( DIR );
+ closedir(DIR);
+
+ my @FOUND = ();
+
+ foreach my $entry ( @entries )
+ {
+ # Skip "dotfiles"
+ next if ( ( $entry =~ /^\.$/ ) or ( $entry =~ /^\.\.$/ ) );
+
+ if ( -d $dir . "/" . $entry )
+ {
+ push @FOUND, &filesInDirRecursively( $dir . "/" . $entry );
+ }
+ }
+
+ return( sort(@FOUND ) );
+}
+
+
+#
# Return all the directories in the given directory
#
# The returned list will be sorted.
--- gnump3d2 2005-11-17 08:46:53.000000000 +0800
+++ gnump3d2.new 2005-12-02 21:52:03.000000000 +0800
@@ -117,6 +117,7 @@
my $jukebox_binary; # The binary to use for playing locally.
my $tag_cache; # The file to cache tag information to.
my $advanced_playlist; # Should we include extra information in .m3u files?
+my $seperate_folders; # Should folders and files be seperated in the playlists?
my $host_rewrite; # Allow rewrites of hostname in m3u
my $meta_tags; # Optional meta tags to include.
@@ -1279,6 +1280,18 @@
$header .= "Content-type: $mime\r\n";
#
+ # If we're serving a playlist, suggest a filename.
+ # This fixes issues with XMMS disliking extended playlists
+ # that are served by plugins - links without .m3u extensions
+ #
+
+ if ( $mime eq "audio/x-mpegurl" )
+ {
+ $header .= "Content-Disposition: attachment; filename=playlist.m3u;\r\n";
+ }
+
+
+ #
# If we're going to serve a file send the last modified
# date + size.
#
@@ -1405,11 +1418,17 @@
my ( $dir, $recursive, $random ) = ( @_ );
my @files = ();
+ my @filesonly = ();
#
# Read in the files for the playlist.
#
- if ( $recursive )
+ if ( ( $recursive ) and ( $seperate_folders ) )
+ {
+ @files = &filesInDirsOnlyRecursively( $dir );
+ @filesonly = &filesInDir( $dir );
+ }
+ elsif ( $recursive )
{
@files = &filesInDirRecursively( $dir );
}
@@ -1454,6 +1473,13 @@
$sorter->setTagCache( $tagCache );
@files = &sortFiles( $sort_order, @files );
+ # Put individual files at the bottom of the playlist
+ if ( ( $seperate_folders ) and ( $recursive ) )
+ {
+ @filesonly = &sortFiles( $sort_order, @filesonly );
+ push( @files, @filesonly );
+ }
+
#
# Process each file that we will include in the playlist.
#
@@ -1473,7 +1499,7 @@
if ( $advanced_playlist )
{
# Set the song format.
- $tagCache->setFormatString( "#EXTINF: \$SECONDS,$song_format" );
+ $tagCache->setFormatString( "#EXTINF:\$SECONDS,$song_format" );
$tags = "";
$tags = getSongDisplay( $file ) . "\n";
@@ -3361,6 +3387,7 @@
$hide_song_tags = getConfig( "hide_song_tags", 0 );
$disable_tag_cache = getConfig( "disable_tag_cache", 0 );
$advanced_playlist = getConfig( "advanced_playlists", 1 );
+ $seperate_folders = getConfig( "seperate_folders", 0 );
# Tag cache
$tag_cache = getConfig( "tag_cache", "" );
_______________________________________________
Gnump3d-users mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnump3d-users