[SCM] morituri/master: * examples/ARcalibrate.py (added): Add an example that calculates the read offset of your drive using AccurateRip.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:08:52 UTC 2014
The following commit has been merged in the master branch:
commit 05e90de6e3f23155ea46e1c6ceaf1a73dfbc4a5d
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Sun May 3 10:08:03 2009 +0000
* examples/ARcalibrate.py (added):
Add an example that calculates the read offset of your drive
using AccurateRip.
diff --git a/ChangeLog b/ChangeLog
index 2f054c2..febf7d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2009-05-03 Thomas Vander Stichele <thomas at apestaart dot org>
+ * examples/ARcalibrate.py (added):
+ Add an example that calculates the read offset of your drive
+ using AccurateRip.
+
+2009-05-03 Thomas Vander Stichele <thomas at apestaart dot org>
+
* morituri/program/cdrdao.py:
Add a task to read the Table.
diff --git a/examples/ARcue.py b/examples/ARcalibrate.py
similarity index 51%
copy from examples/ARcue.py
copy to examples/ARcalibrate.py
index 2de9569..7e7aac6 100644
--- a/examples/ARcue.py
+++ b/examples/ARcalibrate.py
@@ -1,4 +1,4 @@
-# -*- Mode: Python -*-
+# -*- Mode: Python; test-case-name: morituri.test.test_header -*-
# vi:si:et:sw=4:sts=4:ts=4
# Morituri - for those about to RIP
@@ -22,6 +22,7 @@
import os
import sys
+import tempfile
import optparse
import gobject
@@ -29,10 +30,17 @@ gobject.threads_init()
import gtk
from morituri.image import image
-from morituri.common import task, checksum, log
+from morituri.common import task, checksum
+from morituri.program import cdrdao, cdparanoia
+
+"""
+Find read offset by ripping a track from an AccurateRip CD.
+"""
+
+from morituri.common import log
+log.init()
def gtkmain(runner, taskk):
- runner = task.GtkProgressRunner()
runner.connect('stop', lambda _: gtk.main_quit())
window = gtk.Window()
@@ -48,8 +56,6 @@ def climain(runner, taskk):
def main(argv):
- log.init()
-
parser = optparse.OptionParser()
default = 'cli'
@@ -58,18 +64,29 @@ def main(argv):
help="runner ('cli' or 'gtk', defaults to %s)" % default,
default=default)
- options, args = parser.parse_args(argv[1:])
+ # see http://www.accuraterip.com/driveoffsets.htm
+ default = "0, 6, 12, 48, 91, 97, 102, 108, 120, " + \
+ "564, 594, 667, 685, 691, 704, 738, 1194, 1292, 1336, 1776, -582"
+ parser.add_option('-o', '--offsets',
+ action="store", dest="offsets",
+ help="list of offsets, comma-separated, "
+ "colon-separated for ranges (defaults to %s)" %
+ default,
+ default=default)
- path = 'test.cue'
+ options, args = parser.parse_args(argv[1:])
- try:
- path = sys.argv[1]
- except IndexError:
- pass
+ offsets = []
+ blocks = options.offsets.split(',')
+ for b in blocks:
+ if ':' in b:
+ a, b = b.split(':')
+ offsets.extend(range(int(a), int(b) + 1))
+ else:
+ offsets.append(int(b))
- cueImage = image.Image(path)
- verifytask = image.ImageVerifyTask(cueImage)
- cuetask = image.AccurateRipChecksumTask(cueImage)
+ # first get the Table Of Contents of the CD
+ t = cdrdao.ReadTableTask()
if options.runner == 'cli':
runner = task.SyncRunner()
@@ -78,10 +95,11 @@ def main(argv):
runner = task.GtkProgressRunner()
function = gtkmain
- cueImage.setup(runner)
- print
- print "CDDB disc id", cueImage.table.getCDDBDiscId()
- url = cueImage.table.getAccurateRipURL()
+ function(runner, t)
+ table = t.table
+
+ print "CDDB disc id", table.getCDDBDiscId()
+ url = table.getAccurateRipURL()
print "AccurateRip URL", url
# FIXME: download url as a task too
@@ -100,47 +118,34 @@ def main(argv):
if responses:
print '%d AccurateRip reponses found' % len(responses)
- if responses[0].cddbDiscId != cueImage.table.getCDDBDiscId():
+ if responses[0].cddbDiscId != table.getCDDBDiscId():
print "AccurateRip response discid different: %s" % \
responses[0].cddbDiscId
- function(runner, verifytask)
- function(runner, cuetask)
-
response = None
- for i, checksum in enumerate(cuetask.checksums):
- status = 'rip NOT accurate'
-
- confidence = None
- archecksum = None
-
- for j, r in enumerate(responses):
- if "%08x" % checksum == r.checksums[i]:
- if not response:
- response = r
- else:
- assert r == response, \
- "checksum %s for %d matches wrong response %d, "\
- "checksum %s" % (
- checksum, i + 1, j + 1, response.checksums[i])
- status = 'rip accurate '
- archecksum = checksum
- confidence = response.confidences[i]
-
- c = "(not found)"
- ar = ""
- if responses:
- maxConfidence = max(r.confidences[i] for r in responses)
-
- c = "(confidence %3d)" % maxConfidence
- if confidence is not None:
- if confidence < maxConfidence:
- c = "(confidence %3d of %3d)" % (confidence, maxConfidence)
-
- ar = ", AR [%s]" % response.checksums[i]
- print "Track %2d: %s %s [%08x]%s" % (
- i + 1, status, c, checksum, ar)
+ # now rip the first track at various offsets, calculating AccurateRip
+ # CRC, and matching it against the retrieved ones
+ for offset in offsets:
+ fd, path = tempfile.mkstemp(suffix='.morituri')
+ os.close(fd)
+
+ print 'ripping track 1 with offset', offset
+ track = table.tracks[0]
+ t = cdparanoia.ReadTrackTask(path, track.start, track.end, offset)
+ t.description = 'Ripping with offset %d' % offset
+ function(runner, t)
+
+ t = checksum.AccurateRipChecksumTask(path, trackNumber=1,
+ trackCount = len(table.tracks))
+ function(runner, t)
+ arcs = "%08x" % t.checksum
+ print 'AR checksum calculated: %s' % arcs
+
+ for i, r in enumerate(responses):
+ if arcs == r.checksums[0]:
+ print 'MATCHED against response %d' % i
+ print 'offset of device is', offset
main(sys.argv)
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list