From 6f3380a320ef105db4e7a13239c429ef424da3ac Mon Sep 17 00:00:00 2001 From: Jerome Quelin Date: Sat, 24 Sep 2011 11:40:15 +0200 Subject: [PATCH] collection: new methods all_genres / artists_by_genre (sebastien nobili) --- Changes | 2 ++ lib/Audio/MPD/Collection.pm | 31 ++++++++++++++++++++++++++++++- weaver.ini | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 5a49b3d..df85bd5 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/lib/Audio/MPD/Collection.pm b/lib/Audio/MPD/Collection.pm index df12bc8..a6edeb4 100644 --- a/lib/Audio/MPD/Collection.pm +++ b/lib/Audio/MPD/Collection.pm @@ -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 @@ -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 @@ -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; diff --git a/weaver.ini b/weaver.ini index 5db35e5..e06bdab 100644 --- a/weaver.ini +++ b/weaver.ini @@ -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]