Skip to content

Commit

Permalink
collection: new methods all_genres / artists_by_genre (sebastien nobili)
Browse files Browse the repository at this point in the history
  • Loading branch information
jquelin committed Sep 24, 2011
1 parent db63e1a commit 6f3380a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Changelog for Audio-MPD

{{$NEXT}}
- collection: new method all_genres (sebastien nobili)
- collection: new method artists_by_genre (sebastien nobili)

1.111200 2011-04-30 10:21:31 Europe/Paris
- removing misleading example in pod
Expand Down
31 changes: 30 additions & 1 deletion lib/Audio/MPD/Collection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ sub all_playlists {
}


=meth_coll_whole all_genres
my @genres = $coll->all_genres;
Return the list of all genres (strings) currently known by mpd.
=cut

sub all_genres {
my ($self) = @_;
return $self->_mpd->_cooked_command_strip_first_field( "list genre\n" );
}


# -- Collection: picking songs

=meth_coll_pick song
Expand Down Expand Up @@ -227,7 +241,7 @@ sub songs_with_filename_partial {
}


# -- Collection: songs, albums & artists relations
# -- Collection: songs, albums, artists & genres relations

=meth_coll_relations albums_by_artist
Expand Down Expand Up @@ -344,6 +358,21 @@ sub songs_with_title_partial {
}


=meth_coll_relations artists_by_genre
my @artists = $coll->artists_by_genre( $genre );
Return all artists (strings) of C<$genre>.
=cut

sub artists_by_genre {
my ($self, $genre) = @_;
$genre =~ s/"/\\"/g;
return $self->_mpd->_cooked_command_strip_first_field( qq[list artist genre "$genre"\n] );
}


no Moose;
__PACKAGE__->meta->make_immutable;
1;
Expand Down
2 changes: 1 addition & 1 deletion weaver.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ command = meth_coll_pick
header = PICKING A SONG
[Collect / COLL_RELATIONS]
command = meth_coll_relations
header = SONGS, ALBUMS & ARTISTS RELATIONS
header = SONGS, ALBUMS, ARTISTS & GENRES RELATIONS

; audio::mpd::playlist
[Collect / PLAY_INFO]
Expand Down

0 comments on commit 6f3380a

Please sign in to comment.