artist_tracks: use tag constraints
authorIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 19:01:54 +0000 (20:01 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 19:01:54 +0000 (20:01 +0100)
lib/ID3FS/DB.pm

index f0ec02a..ef5ea05 100644 (file)
@@ -293,8 +293,11 @@ sub artist_albums
 
 sub artist_tracks
 {
-    my($self, $artist_id)=@_;
-    my $sql=("SELECT files.name FROM files\n\t" .
+    my($self, $artist_id, @constraints)=@_;
+    my $sql=("SELECT files.name FROM (\n" .
+            $self->tags_subselect(@constraints) .
+            "\t) AS subselect\n" .
+            "INNER JOIN files ON subselect.files_id=files.id\n" .
             "INNER JOIN artists ON artists.id=files.artists_id\n\t" .
             "INNER JOIN albums  ON albums.id=files.albums_id\n\t" .
             "WHERE artists.id=? AND albums.name=''\n\t" .
@@ -327,7 +330,7 @@ sub tracks
     # FIXME: rework PathElements
     if(ref($constraints[$#constraints]) eq "ID3FS::PathElement::Artist")
     {
-       return $self->artist_tracks($constraints[$#constraints]->{id});
+       return $self->artist_tracks($constraints[$#constraints]->{id}, @constraints);
     }
     elsif(ref($constraints[$#constraints]) eq "ID3FS::PathElement::Album")
     {