From: EinvalSledge@gmail.com Date: Sat, 19 May 2012 17:50:13 +0000 (+0000) Subject: * When using Musicbrainz, checksum and only output unique matches for an X-Git-Url: https://git.hcoop.net/clinton/abcde.git/commitdiff_plain/efe231408623824b96b906019901eb35b38524be * When using Musicbrainz, checksum and only output unique matches for an album. Closes: #669143 git-svn-id: http://abcde.googlecode.com/svn/trunk@335 a0fa61bc-5347-0410-a1a9-7f54aa4e1825 --- diff --git a/abcde-musicbrainz-tool b/abcde-musicbrainz-tool index 8a7391e..4f2021b 100644 --- a/abcde-musicbrainz-tool +++ b/abcde-musicbrainz-tool @@ -43,6 +43,12 @@ if (!defined($workdir)) { $workdir = "/tmp"; } +sub calc_sha1($) { + my $filename = shift; + my $s = Digest::SHA->new(1); + $s->addfile($filename); + return $s->hexdigest; +} if ($command =~ m/^id/) { my $disc = new MusicBrainz::DiscID($device); @@ -68,6 +74,7 @@ if ($command =~ m/^id/) { my $response = $ws->search({ DISCID => $discid }); my @releases = $response->release_list(); my $releasenum = 0; + my @sums; foreach my $release (@releases) { my $a_artist = $release->artist()->name(); @@ -119,6 +126,18 @@ if ($command =~ m/^id/) { print OUT "PLAYORDER=\n"; print OUT ".\n"; close OUT; + + # Check to see that this entry is unique; generate a checksum + # and compare to any previous checksums + my $checksum = calc_sha1("$workdir/cddbread.$releasenum"); + foreach my $sum (@sums) { + if ($checksum eq $sum) { + unlink("$workdir/cddbread.$releasenum"); + $releasenum--; + last; + } + } + push (@sums, $checksum); } } elsif ($command =~ m/calcid/) { # Calculate MusicBrainz ID from disc offsets; see diff --git a/changelog b/changelog index dcef82f..dad13d1 100644 --- a/changelog +++ b/changelog @@ -6,6 +6,8 @@ abcde 2.5.3 UNRELEASED users. * Fix encoding call for m4a. (Closes issue 31). * Fix do_musicbrainz() for the case where there are no matches. + * When using Musicbrainz, checksum and only output unique matches for an + album. Closes: #669143 -- Steve McIntyre <93sam@debian.org> Mon, 30 Apr 2012 16:59:14 +0100