From 051dc33049ec6f0d18ad1a1c6b423441c3a5bf16 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Mon, 13 Apr 2009 20:00:11 +0000 Subject: [PATCH] * examples/ARcue.py: Make output a bit nicer, mentioning whether tracks were accurately ripped. --- ChangeLog | 6 ++++++ examples/ARcue.py | 34 +++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 848bf76..37db8ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-04-13 Thomas Vander Stichele + + * examples/ARcue.py: + Make output a bit nicer, mentioning whether tracks were + accurately ripped. + 2009-04-13 Thomas Vander Stichele * morituri/image/image.py: diff --git a/examples/ARcue.py b/examples/ARcue.py index f37aa82..462e04d 100644 --- a/examples/ARcue.py +++ b/examples/ARcue.py @@ -20,6 +20,7 @@ # You should have received a copy of the GNU General Public License # along with morituri. If not, see . +import os import sys import optparse @@ -69,21 +70,32 @@ def main(argv): if options.runner == 'cli': runner = task.SyncRunner() - cueImage.setup(runner) - print "CDDB disc id", cueImage.getCDDBDiscId() - print "AccurateRip URL", cueImage.getAccurateRipURL() - climain(runner, verifytask) - climain(runner, cuetask) + function = climain elif options.runner == 'gtk': runner = task.GtkProgressRunner() - cueImage.setup(runner) - print "CDDB disc id", cueImage.getCDDBDiscId() - print "AccurateRip URL", cueImage.getAccurateRipURL() - gtkmain(runner, verifytask) - gtkmain(runner, cuetask) + function = gtkmain + + cueImage.setup(runner) + print "CDDB disc id", cueImage.getCDDBDiscId() + url = cueImage.getAccurateRipURL() + print "AccurateRip URL", url + + # FIXME: download url as a task too + import urllib + (filename, headers) = urllib.urlretrieve(url) + data = open(filename, 'rb').read() + os.unlink(filename) + response = image.AccurateRipResponse(data) + + function(runner, verifytask) + function(runner, cuetask) for i, crc in enumerate(cuetask.crcs): - print "Track %2d: %08x" % (i + 1, crc) + status = ' rip accurate ' + if "%08x" % crc != response.crcs[i]: + status = '** rip not accurate **' + print "Track %2d: %s (confidence %d) [%08x] [%s]" % ( + i + 1, status, response.confidences[i], crc, response.crcs[i]) main(sys.argv)