diff --git a/ChangeLog b/ChangeLog index 0eb76f3..0239ccc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-05-01 Thomas Vander Stichele + + * examples/readhtoa.py (added): + Add an example that detects and rips the Hidden Track One Audio. + 2009-05-01 Thomas Vander Stichele * examples/readtoc.py: diff --git a/examples/readhtoa.py b/examples/readhtoa.py new file mode 100644 index 0000000..c63dc78 --- /dev/null +++ b/examples/readhtoa.py @@ -0,0 +1,63 @@ +# -*- Mode: Python -*- +# vi:si:et:sw=4:sts=4:ts=4 + +import os +import tempfile +import shutil + +from morituri.common import task, checksum, log +from morituri.program import cdrdao, cdparanoia + +import gobject +gobject.threads_init() + +def main(): + log.init() + runner = task.SyncRunner() + t = cdrdao.ReadTOCTask() + runner.run(t) + + # now check if we have a hidden track one audio + track = t.toc.tracks[0] + try: + index = track.getIndex(0) + except KeyError: + print 'No Hidden Track One Audio found.' + return + + start = index[0] + stop, _ = track.getIndex(1) + print 'Found Hidden Track One Audio from frame %d to %d' % (start, stop) + + # rip it + + checksums = [] + + for i in range(2): + fd, path = tempfile.mkstemp(suffix='.morituri', dir=os.getcwd()) + os.close(fd) + + t = cdparanoia.ReadTrackTask(path, start, stop - 1, offset=0) + if i == 1: + t.description = 'Verifying track...' + + runner.run(t) + + t = checksum.CRC32Task(path) + runner.run(t) + + if i == 0: + os.unlink(path) + + checksums.append(t.checksum) + + print 'runner done' + if checksums[0] == checksums[1]: + print 'Checksums match' + shutil.move(path, 'track00.wav') + else: + print 'Checksums did not match' + os.unlink(path) + + +main()