From a1b0cc1f04007f1e5d8c135096e59787d478b07c Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sun, 26 Sep 2010 03:43:15 +0100 Subject: [PATCH] key albums off artists too (otherwise we get dylan's unplugged in radiohead's unplugged directory) --- lib/ID3FS/DB.pm | 20 ++++++++++++++------ lib/ID3FS/Path.pm | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/ID3FS/DB.pm b/lib/ID3FS/DB.pm index 858e068..30510fe 100644 --- a/lib/ID3FS/DB.pm +++ b/lib/ID3FS/DB.pm @@ -280,13 +280,14 @@ sub artist_tracks sub album_tracks { - my($self, $album_id)=@_; + my($self, $artist_id, $album_id)=@_; my $sql=("SELECT files.name FROM files\n\t" . - "INNER JOIN albums ON albums.id=files.albums_id\n\t" . - "WHERE albums.id=?\n\t" . #AND albums.name <> ''\n\t" . + "INNER JOIN albums ON albums.id=files.albums_id\n\t" . + "INNER JOIN artists ON artists.id=files.artists_id\n\t" . + "WHERE artists.id=? AND albums.id=?\n\t" . "GROUP BY files.name\n"); - print "ALBUM_TRACKS SQL($album_id): $sql\n"; - my $result=$self->cmd_rows($sql, $album_id); + print "ALBUM_TRACKS SQL($artist_id, $album_id): $sql\n"; + my $result=$self->cmd_rows($sql, $artist_id, $album_id); my @names=map { $_->[0]; } @$result; @names = map { s/.*\///; $_;} @names; print "TRACKS: ", join(', ', @names), "\n"; @@ -303,7 +304,14 @@ sub tracks } elsif(ref($constraints[$#constraints]) eq "ID3FS::PathElement::Album") { - return $self->album_tracks($constraints[$#constraints]->{id}); + my $artist_id=0; + my $artist=$constraints[($#constraints)-1]; + if(defined($artist) && (ref($artist) eq "ID3FS::PathElement::Artist")) + { + # should always happen + $artist_id=$artist->{id}; + } + return $self->album_tracks($artist_id, $constraints[$#constraints]->{id}); } my $main_sql_start=("SELECT files.name\n" . diff --git a/lib/ID3FS/Path.pm b/lib/ID3FS/Path.pm index 3440780..076b6ca 100644 --- a/lib/ID3FS/Path.pm +++ b/lib/ID3FS/Path.pm @@ -225,7 +225,6 @@ sub parse else { my $album=ID3FS::PathElement::Album->new($self->{db}, $name); - push(@{$self->{elements}}, $album); if($album) { push(@{$self->{elements}}, $album); -- 2.11.0