/usr/bin/mpd-dump-ratings is in libaudio-mpd-perl 2.004-2.
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | #!/usr/bin/perl
#
# 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 strict;
use warnings;
use 5.010;
# PODNAME: mpd-dump-ratings
# ABSTRACT: dump mpd ratings & filter them
use DB_File;
use Encode;
use Getopt::Euclid;
use List::MoreUtils qw[ all ];
my %db;
tie %db, 'DB_File', "$ENV{HOME}/.mpd/ratings.db";
my $music = '/home/jquelin/Music';
FILENAME:
foreach my $file (sort keys %db) {
# minimum rating
next unless $db{$file} >= $ARGV{-min};
# match some pattern(s)
next if exists $ARGV{'<pattern>'}
&& not all { $file =~ /$_/i } @{ $ARGV{'<pattern>'} };
# orphan files
if ( $ARGV{-orphan} ) {
next if -f "$music/$file";
# trying to repair
if ( $ARGV{-repair} ) {
my $utf = encode('utf-8', $file);
if ( -f "$music/$utf" ) {
print "$db{$file}: $utf [utf8]";
if ( exists($db{$utf}) && defined($db{$utf}) ) {
# duplicate rating
print "[duplicate]";
if ( $db{$utf} == $db{$file} ) {
delete $db{$file};
say "[fixed]";
} else {
say "[mismatch $db{$file}!=$db{$utf}]";
print "enter new rating: ";
my $rate = <STDIN>;
chomp $rate;
$db{$utf} = $rate;
delete $db{$file};
}
} else {
# ok, single rating, convert to utf8
$db{$utf} = $db{$file};
delete $db{$file};
say "[fixed]";
}
} else {
if ( $ARGV{-delete} ) {
say "$db{$file}: $file [delete]";
delete $db{$file};
} else {
say "$db{$file}: $file [orphan]";
}
}
next; #
}
}
print "$db{$file}: $file\n";
}
__END__
=pod
=head1 NAME
mpd-dump-ratings - dump mpd ratings & filter them
=head1 VERSION
version 2.004
=head1 DESCRIPTION
Dumps the mpd ratings associated to songs. Each filename will be dumped
on a line with a prefix "rating: ". One can filter out the filenames
dumped with some options.
=head1 NAME
mpd-dump-ratings - dump mpd ratings
=head1 USAGE
mpd-dump-ratings [options]
=head1 OPTIONS
=over 4
=item -m[in[imum]] [=] <min>
Minimum rating for a song to be displayed. Default to 0.
=for Euclid: min.type: int > 0
min.default: 0
=item -o[rphan[ed]]
Print only orphan pathes (ie, with no matching filename).
=item -r[epair]
Try to fix the database for orphan pathes (ie, doesn't work if
C<-orphan> is not supplied). Existing fixes performed:
=over 4
=item try to convert orphan path to utf8.
=back
If one of those fix leads to a valid path, it will try to fix database.
Of course, it checks if this leads to duplicate values.
=item -d[elete]
If C<-repair> did not manage to find a plausible replacement for the
orphan rating, then it will remove this rating from the database. This
can be the case when you removed a song...
B<Warning>: you will potentially loose some information!
=item <pattern>
Filter out songs that don't match given C<pattern>.
=for Euclid: repeatable
pattern.type: string
pattern.default: ''
=item --version
=item --usage
=item --help
=item --man
Print the usual program information
=back
=head1 AUTHOR
Jerome Quelin, "<jquelin at cpan.org>"
=head1 COPYRIGHT & LICENSE
Copyright (c) 2008 Jerome Quelin, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=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
|