diff --git a/bin/mpd-dynamic b/bin/mpd-dynamic index 975a5c5..ee1080b 100755 --- a/bin/mpd-dynamic +++ b/bin/mpd-dynamic @@ -23,6 +23,8 @@ Proc::Daemon::Init unless $ARGV{debug}; # fetch list of songs known by mpd. my @files = $mpd->collection->all_pathes; +die "Please set up mpd's audio collection before running mpd-dynamic" + unless @files; while (1) { # endless loop @@ -37,7 +39,7 @@ while (1) { # endless loop # yup - update playlist & song. $playlist = $status->playlist; - $song = $status->song; + $song = $status->song // 0; # keep at most $ARGV{old} songs. if ( $song > $ARGV{old} ) { diff --git a/bin/mpd-rate b/bin/mpd-rate index 87b63a7..b262e5f 100755 --- a/bin/mpd-rate +++ b/bin/mpd-rate @@ -13,7 +13,12 @@ use Encode; use Getopt::Euclid qw{ :minimal_keys }; # fetch current song -my $song = encode( 'utf-8', Audio::MPD->new->current->file ); +my $playing = Audio::MPD->new->current; +unless (defined $playing) +{ + die "Cannot rate current song, as no song currently is playing!"; +} +my $song = encode( 'utf-8', $playing->file ); # open ratings file my %ratings;