Skip to content

Commit

Permalink
rt#75436 - mpd-rate and mpd-dynamic should fail gracefully when no so…
Browse files Browse the repository at this point in the history
…ng is playing
  • Loading branch information
jquelin committed Mar 1, 2012
1 parent be330ce commit 84340aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bin/mpd-dynamic
Expand Up @@ -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
Expand All @@ -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} ) {
Expand Down
7 changes: 6 additions & 1 deletion bin/mpd-rate
Expand Up @@ -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;
Expand Down

0 comments on commit 84340aa

Please sign in to comment.