/usr/bin/mpd-rate is in libaudio-mpd-perl 2.000-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
#
# This file is part of Audio-MPD
#
# This software is copyright (c) 2007 by Jerome Quelin.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use 5.010;
use strict;
use warnings;
# PODNAME: mpd-rate;
# ABSTRACT: rate your songs for mpd-dynamic
use Audio::MPD;
use DB_File;
use Encode;
use Getopt::Euclid qw{ :minimal_keys };
# fetch current song
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;
tie %ratings, 'DB_File', $ARGV{ratings}, O_RDWR|O_CREAT, oct(666), $DB_HASH
or die "$ARGV{ratings}: $!";
# update rating or print it
if ( defined $ARGV{rating} ) { $ratings{$song} = $ARGV{rating}; }
else { say exists $ratings{$song} ? $ratings{$song} : 0; }
untie %ratings;
__END__
=pod
=head1 NAME
mpd-rate; - rate your songs for mpd-dynamic
=head1 VERSION
version 2.000
=head1 DESCRIPTION
This program allows you to rate your songs, to allow mpd-dynamic to use ratings.
=head1 USAGE
mpd-rate [options]
=head1 OPTIONS
You can customize the usage of mpd-dynamic with the following options:
=over 4
=item -r[atings] <ratings>
The path of a db file with the ratings per song. The keys are the song path
(relative to MPD root), and the value is an integer (the rating). Default to
C<~/.mpd/ratings.db>.
=for Euclid: ratings.type: writable
ratings.default: "$ENV{HOME}/.mpd/ratings.db"
=item <rating>
The rating you want to apply to the current song. If not supplied, will
print its current rating.
=for Euclid: rating.type: integer
=item --version
=item --usage
=item --help
=item --man
Print the usual program information
=back
=head1 AUTHOR
Jerome Quelin
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|