- my @names=map { $_->[0]; } @$result;
- print "ALBUMS: ", join(', ', @names), "\n";
- return(@names);
-}
-
-sub artist_albums
-{
- my($self, $artist_id)=@_;
- my $sql=("SELECT albums.name FROM files\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.name <> ''\n\t" .
- "GROUP BY albums.name\n");
- print "ARTIST_ALBUMS SQL: $sql\n";
- my $result=$self->cmd_rows($sql, $artist_id);
- my @albums=map { $_->[0]; } @$result;
- print "ALBUMS: ", join(', ', @albums), "\n";
- return(@albums);
-}
-
-sub artist_tracks
-{
- my($self, $artist_id)=@_;
- my $sql=("SELECT files.name FROM files\n\t" .
- "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" .
- "GROUP BY files.name\n");
- print "ARTIST_TRACKS SQL: $sql\n";
- my $result=$self->cmd_rows($sql, $artist_id);
- my @names=map { $_->[0]; } @$result;
- print "ARTISTTRACKS: ", join(', ', @names), "\n";
- return(@names);
-}
-
-sub album_tracks
-{
- 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" .
- "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($artist_id, $album_id): $sql\n";
- my $result=$self->cmd_rows($sql, $artist_id, $album_id);
- my @names=map { $_->[0]; } @$result;
- print "TRACKS: ", join(', ', @names), "\n";
- return(@names);
-}
-
-sub tracks
-{
- my($self, @constraints)=@_;
- # FIXME: rework PathElements
- if(ref($constraints[$#constraints]) eq "ID3FS::PathElement::Artist")
- {
- return $self->artist_tracks($constraints[$#constraints]->{id});
- }
- elsif(ref($constraints[$#constraints]) eq "ID3FS::PathElement::Album")
- {
- 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" .
- "\tFROM (SELECT files_id FROM tags\n" .
- "\t\tINNER JOIN files_x_tags ON tags.id=files_x_tags.tags_id\n" .
- "\t\tWHERE tags.id in\n\t\t\t(");
- my $main_sql_end=(")\n\t\t) AS subselect\n" .
- "\tINNER JOIN files ON files.id=subselect.files_id" .
- "\tGROUP BY files.name;");
- my @ids;
- while(my $constraint=shift @constraints)