def do(self, args): from morituri.common import encode profile = encode.ALL_PROFILES[self.options.profile]() try: fromPath = unicode(args[0]) except IndexError: self.stdout.write('Please specify an input file.\n') return 3 try: toPath = unicode(args[1]) except IndexError: toPath = fromPath + '.' + profile.extension runner = task.SyncRunner() self.debug('Encoding %s to %s', fromPath.encode('utf-8'), toPath.encode('utf-8')) encodetask = encode.EncodeTask(fromPath, toPath, profile) runner.run(encodetask) self.stdout.write('Peak level: %r\n' % encodetask.peak) self.stdout.write('Encoded to %s\n' % toPath.encode('utf-8'))
def do(self, args): prog = program.Program(self.getRootCommand().config) runner = ctask.SyncRunner() device = self.options.device # if necessary, load and unmount self.stdout.write('Checking device %s\n' % device) prog.loadDevice(device) prog.unmountDevice(device) # first get the Table Of Contents of the CD t = cdrdao.ReadTOCTask(device) table = t.table self.debug("CDDB disc id: %r", table.getCDDBDiscId()) url = table.getAccurateRipURL() self.debug("AccurateRip URL: %s", url) # FIXME: download url as a task too responses = [] import urllib2 try: handle = urllib2.urlopen(url) data = handle.read() responses = accurip.getAccurateRipResponses(data) except urllib2.HTTPError, e: if e.code == 404: self.stdout.write( 'Album not found in AccurateRip database.\n') return 1 else: raise
def main(argv): parser = optparse.OptionParser() default = 'cli' parser.add_option('-r', '--runner', action="store", dest="runner", help="runner ('cli' or 'gtk', defaults to %s)" % default, default=default) options, args = parser.parse_args(argv[1:]) taglist = gst.TagList() taglist[gst.TAG_ARTIST] = 'Thomas' taglist[gst.TAG_TITLE] = 'Yes' taskk = encode.EncodeTask(args[0], args[1], taglist=taglist) if options.runner == 'cli': runner = task.SyncRunner() function = climain elif options.runner == 'gtk': runner = taskgtk.GtkProgressRunner() function = gtkmain function(runner, taskk)
def main(): log.init() runner = task.SyncRunner() checksums = [] if len(sys.argv) > 1: path = sys.argv[1] else: fd, path = tempfile.mkstemp(suffix='.morituri.wav') os.close(fd) print 'storing track to %s' % path fakeTable = table.Table([ table.Track( 1, 0, 15536), ]) t = cdparanoia.ReadVerifyTrackTask(path, fakeTable, 1000, 3000, offset=0) runner.run(t) print 'runner done' if t.checksum is not None: print 'Checksums match' else: print 'Checksums do not match'
def main(): log.init() parser = optparse.OptionParser() default = 0 parser.add_option('-o', '--offset', action="store", dest="offset", help="sample offset (defaults to %d)" % default, default=default) options, args = parser.parse_args(sys.argv[1:]) runner = task.SyncRunner() # first do a simple TOC scan t = cdrdao.ReadTOCTask() runner.run(t) toc = t.table offset = t.table.tracks[0].getIndex(1).absolute if offset < 150: print 'Disc is unlikely to have Hidden Track One Audio.' else: print 'Disc seems to have a %d frame HTOA.' % offset # now do a more extensive scan t = cdrdao.ReadTableTask() runner.run(t) # now check if we have a hidden track one audio track = t.table.tracks[0] try: index = track.getIndex(0) except KeyError: print 'No Hidden Track One Audio found.' return start = index.absolute stop = track.getIndex(1).absolute print 'Found Hidden Track One Audio from frame %d to %d' % (start, stop) # rip it riptask = cdparanoia.ReadVerifyTrackTask('track00.wav', t.table, start, stop - 1, offset=int(options.offset)) runner.run(riptask) print 'runner done' if riptask.checksum is not None: print 'Checksums match' else: print 'Checksums did not match'
def main(argv): parser = optparse.OptionParser() default = 'cli' parser.add_option('-r', '--runner', action="store", dest="runner", help="runner ('cli' or 'gtk', defaults to %s)" % default, default=default) parser.add_option('-p', '--playlist', action="store", dest="playlist", help="playlist to analyze files from") parser.add_option('-P', '--pickle', action="store", dest="pickle", help="pickle to store trms to") options, args = parser.parse_args(argv[1:]) paths = [] if len(args) > 0: paths.extend(args[0:]) if options.playlist: paths.extend(open(options.playlist).readlines()) mtask = task.MultiCombinedTask() listener = None ptrms = common.Persister(options.pickle or None, {}) if options.pickle: listener = Listener(ptrms) print 'Using pickle %s' % options.pickle trms = ptrms.object for path in paths: path = path.rstrip() if path in trms.keys(): continue trmtask = checksum.TRMTask(path) if listener: trmtask.addListener(listener) mtask.addTask(trmtask) mtask.description = 'Fingerprinting files' if options.runner == 'cli': runner = task.SyncRunner() function = climain elif options.runner == 'gtk': runner = taskgtk.GtkProgressRunner() function = gtkmain function(runner, mtask) print for trmtask in mtask.tasks: print trmtask.trm
def _testSuffix(self, suffix): self.runner = ctask.SyncRunner(verbose=False) fd, path = tempfile.mkstemp(suffix=suffix) checksumtask = checksum.ChecksumTask(path) e = self.assertRaises(task.TaskException, self.runner.run, checksumtask, verbose=False) self.failUnless(isinstance(e.exception, gstreamer.GstException)) os.unlink(path)
def testEmpty(self): # this test makes sure that checksumming empty files doesn't hang self.runner = ctask.SyncRunner(verbose=False) fd, path = tempfile.mkstemp(suffix=u'morituri.test.empty') checksumtask = checksum.ChecksumTask(path) # FIXME: do we want a specific error for this ? e = self.assertRaises(task.TaskException, self.runner.run, checksumtask, verbose=False) self.failUnless(isinstance(e.exception, gstreamer.GstException)) os.unlink(path)
def main(): log.init() runner = task.SyncRunner() t = cdrdao.ReadTableTask() runner.run(t) print 'runner done', t.toc if not t.table: print 'Failed to read TOC' return for track in t.table.tracks: print track.getIndex(1).absolute
def main(argv): log.init() parser = optparse.OptionParser() default = 'cli' parser.add_option('-r', '--runner', action="store", dest="runner", help="runner ('cli' or 'gtk', defaults to %s)" % default, default=default) options, args = parser.parse_args(argv[1:]) path = 'test.cue' try: path = sys.argv[1] except IndexError: pass cueImage = image.Image(path) verifytask = image.ImageVerifyTask(cueImage) cuetask = image.AccurateRipChecksumTask(cueImage) if options.runner == 'cli': runner = task.SyncRunner() function = climain elif options.runner == 'gtk': runner = taskgtk.GtkProgressRunner() function = gtkmain cueImage.setup(runner) print print "CDDB disc id", cueImage.table.getCDDBDiscId() url = cueImage.table.getAccurateRipURL() print "AccurateRip URL", url # FIXME: download url as a task too responses = [] import urllib2 try: handle = urllib2.urlopen(url) data = handle.read() responses = accurip.getAccurateRipResponses(data) except urllib2.HTTPError, e: if e.code == 404: print 'Album not found in AccurateRip database' else: raise
def do(self, args): try: fromPath = unicode(args[0]) except IndexError: self.stdout.write('Please specify an input file.\n') return 3 runner = task.SyncRunner() # here to avoid import gst eating our options from morituri.common import checksum checksumtask = checksum.CRC32Task(fromPath) runner.run(checksumtask) self.stdout.write('Checksum: %08x\n' % checksumtask.checksum)
def do(self, args): try: path = unicode(args[0]) except IndexError: self.stdout.write('Please specify an input file.\n') return 3 runner = task.SyncRunner() from morituri.common import encode self.debug('Reading tags from %s' % path.encode('utf-8')) tagtask = encode.TagReadTask(path) runner.run(tagtask) for key in tagtask.taglist.keys(): self.stdout.write('%s: %r\n' % (key, tagtask.taglist[key]))
def do(self, args): if not args: self.stdout.write('Please specify one or more input files.\n') return 3 runner = task.SyncRunner() # here to avoid import gst eating our options from morituri.common import checksum for arg in args: fromPath = unicode(arg) checksumtask = checksum.CRC32Task(fromPath) runner.run(checksumtask) self.stdout.write('Checksum: %08x\n' % checksumtask.checksum)
def do(self, args): if not args: self.stdout.write('Please specify one or more input files.\n') return 3 runner = task.SyncRunner() # here to avoid import gst eating our options from morituri.common import checksum for arg in args: fromPath = unicode(arg.decode('utf-8')) checksumtask = checksum.MaxSampleTask(fromPath) runner.run(checksumtask) self.stdout.write('%s\n' % arg) self.stdout.write('Biggest absolute sample: %04x\n' % checksumtask.checksum)
def do(self, args): prog = program.Program(self.getRootCommand().config) runner = ctask.SyncRunner() device = self.options.device # if necessary, load and unmount self.stdout.write('Checking device %s\n' % device) prog.loadDevice(device) prog.unmountDevice(device) # first get the Table Of Contents of the CD t = cdrdao.ReadTOCTask(device=device) try: runner.run(t) except cdrdao.DeviceOpenException, e: self.error(e.msg) return 3
def main(argv): parser = optparse.OptionParser() default = 'cli' parser.add_option('-r', '--runner', action="store", dest="runner", help="runner ('cli' or 'gtk', defaults to %s)" % default, default=default) # 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) options, args = parser.parse_args(argv[1:]) 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)) # first get the Table Of Contents of the CD t = cdrdao.ReadTOCTask() if options.runner == 'cli': runner = task.SyncRunner() function = climain elif options.runner == 'gtk': from morituri.common import taskgtk runner = taskgtk.GtkProgressRunner() function = gtkmain 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 responses = [] import urllib2 try: handle = urllib2.urlopen(url) data = handle.read() responses = image.getAccurateRipResponses(data) except urllib2.HTTPError, e: if e.code == 404: print 'Album not found in AccurateRip database' sys.exit(1) else: raise
def do(self, args): self.program = program.Program(self.getRootCommand().config, record=self.getRootCommand().record, stdout=self.stdout) self.runner = task.SyncRunner() # if the device is mounted (data session), unmount it self.device = self.parentCommand.options.device self.stdout.write('Checking device %s\n' % self.device) self.program.loadDevice(self.device) self.program.unmountDevice(self.device) # first, read the normal TOC, which is fast self.ittoc = self.program.getFastToc(self.runner, self.options.toc_pickle, self.device) # already show us some info based on this self.program.getRipResult(self.ittoc.getCDDBDiscId()) self.stdout.write("CDDB disc id: %s\n" % self.ittoc.getCDDBDiscId()) self.mbdiscid = self.ittoc.getMusicBrainzDiscId() self.stdout.write("MusicBrainz disc id %s\n" % self.mbdiscid) self.stdout.write("MusicBrainz lookup URL %s\n" % self.ittoc.getMusicBrainzSubmitURL()) self.program.metadata = self.program.getMusicBrainz( self.ittoc, self.mbdiscid, release=self.options.release_id, country=self.options.country, prompt=self.options.prompt) if not self.program.metadata: # fall back to FreeDB for lookup cddbid = self.ittoc.getCDDBValues() cddbmd = self.program.getCDDB(cddbid) if cddbmd: self.stdout.write('FreeDB identifies disc as %s\n' % cddbmd) # also used by rip cd info if not getattr(self.options, 'unknown', False): if self.eject: self.program.ejectDevice(self.device) return -1 # Hackish fix for broken commit offset = 0 info = drive.getDeviceInfo(self.parentCommand.options.device) if info: try: offset = self.getRootCommand().config.getReadOffset(*info) except KeyError: pass # now, read the complete index table, which is slower self.itable = self.program.getTable(self.runner, self.ittoc.getCDDBDiscId(), self.ittoc.getMusicBrainzDiscId(), self.device, offset) assert self.itable.getCDDBDiscId() == self.ittoc.getCDDBDiscId(), \ "full table's id %s differs from toc id %s" % ( self.itable.getCDDBDiscId(), self.ittoc.getCDDBDiscId()) assert self.itable.getMusicBrainzDiscId() == \ self.ittoc.getMusicBrainzDiscId(), \ "full table's mb id %s differs from toc id mb %s" % ( self.itable.getMusicBrainzDiscId(), self.ittoc.getMusicBrainzDiscId()) assert self.itable.getAccurateRipURL() == \ self.ittoc.getAccurateRipURL(), \ "full table's AR URL %s differs from toc AR URL %s" % ( self.itable.getAccurateRipURL(), self.ittoc.getAccurateRipURL()) if self.program.metadata: self.program.metadata.discid = self.ittoc.getMusicBrainzDiscId() # result self.program.result.cdrdaoVersion = cdrdao.getCDRDAOVersion() self.program.result.cdparanoiaVersion = \ cdparanoia.getCdParanoiaVersion() info = drive.getDeviceInfo(self.parentCommand.options.device) if info: try: self.program.result.cdparanoiaDefeatsCache = \ self.getRootCommand().config.getDefeatsCache(*info) except KeyError, e: self.debug('Got key error: %r' % (e, ))
def main(argv): parser = optparse.OptionParser() default = 'cli' parser.add_option('-r', '--runner', action="store", dest="runner", help="runner ('cli' or 'gtk', defaults to %s)" % default, default=default) default = 0 parser.add_option('-o', '--offset', action="store", dest="offset", help="sample offset (defaults to %d)" % default, default=default) parser.add_option('-t', '--table-pickle', action="store", dest="table_pickle", help="pickle to use for reading and writing the table", default=default) parser.add_option('-T', '--toc-pickle', action="store", dest="toc_pickle", help="pickle to use for reading and writing the TOC", default=default) default = '%A - %d/%t. %a - %n' parser.add_option('', '--track-template', action="store", dest="track_template", help="template for track file naming (default %s)" % default, default=default) default = '%A - %d/%A - %d' parser.add_option('', '--disc-template', action="store", dest="disc_template", help="template for disc file naming (default %s)" % default, default=default) options, args = parser.parse_args(argv[1:]) if options.runner == 'cli': runner = task.SyncRunner() function = climain elif options.runner == 'gtk': from morituri.common import taskgtk runner = taskgtk.GtkProgressRunner() function = gtkmain # first, read the normal TOC, which is fast ptoc = common.Persister(options.toc_pickle or None) if not ptoc.object: t = cdrdao.ReadTOCTask() function(runner, t) ptoc.persist(t.table) ittoc = ptoc.object assert ittoc.hasTOC() # already show us some info based on this print "CDDB disc id", ittoc.getCDDBDiscId() metadata = musicbrainz(ittoc.getMusicBrainzDiscId()) # now, read the complete index table, which is slower ptable = common.Persister(options.table_pickle or None) if not ptable.object: t = cdrdao.ReadTableTask() function(runner, t) ptable.persist(t.table) itable = ptable.object assert itable.hasTOC() assert itable.getCDDBDiscId() == ittoc.getCDDBDiscId(), \ "full table's id %s differs from toc id %s" % ( itable.getCDDBDiscId(), ittoc.getCDDBDiscId()) assert itable.getMusicBrainzDiscId() == ittoc.getMusicBrainzDiscId() lastTrackStart = 0 # check for hidden track one audio htoapath = None index = None track = itable.tracks[0] try: index = track.getIndex(0) except KeyError: pass if index: start = index.absolute stop = track.getIndex(1).absolute print 'Found Hidden Track One Audio from frame %d to %d' % (start, stop) # rip it htoapath = getPath(options.track_template, metadata, -1) + '.wav' htoalength = stop - start if not os.path.exists(htoapath): print 'Ripping track %d: %s' % (0, os.path.basename(htoapath)) t = cdparanoia.ReadVerifyTrackTask(htoapath, ittoc, start, stop - 1, offset=int(options.offset)) function(runner, t) if t.checksum: print 'Checksums match for track %d' % 0 else: print 'ERROR: checksums did not match for track %d' % 0 # overlay this rip onto the Table itable.setFile(1, 0, htoapath, htoalength, 0) for i, track in enumerate(itable.tracks): path = getPath(options.track_template, metadata, i) + '.wav' dirname = os.path.dirname(path) if not os.path.exists(dirname): os.makedirs(dirname) # FIXME: optionally allow overriding reripping if not os.path.exists(path): print 'Ripping track %d: %s' % (i + 1, os.path.basename(path)) t = cdparanoia.ReadVerifyTrackTask(path, ittoc, ittoc.getTrackStart(i + 1), ittoc.getTrackEnd(i + 1), offset=int(options.offset)) t.description = 'Reading Track %d' % (i + 1) function(runner, t) if t.checksum: print 'Checksums match for track %d' % (i + 1) else: print 'ERROR: checksums did not match for track %d' % (i + 1) # overlay this rip onto the Table itable.setFile(i + 1, 1, path, ittoc.getTrackLength(i + 1), i + 1) ### write disc files discName = getPath(options.disc_template, metadata, i) dirname = os.path.dirname(discName) if not os.path.exists(dirname): os.makedirs(dirname) # write .cue file cuePath = '%s.cue' % discName handle = open(cuePath, 'w') handle.write(itable.cue()) handle.close() # write .m3u file m3uPath = '%s.m3u' % discName handle = open(m3uPath, 'w') handle.write('#EXTM3U\n') if htoapath: handle.write('#EXTINF:%d,%s\n' % ( htoalength / common.FRAMES_PER_SECOND, os.path.basename(htoapath[:-4]))) handle.write('%s\n' % os.path.basename(htoapath)) for i, track in enumerate(itable.tracks): path = getPath(options.track_template, metadata, i) + '.wav' handle.write('#EXTINF:%d,%s\n' % ( itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND, os.path.basename(path))) handle.write('%s\n' % os.path.basename(path)) handle.close() # verify using accuraterip print "CDDB disc id", itable.getCDDBDiscId() print "MusicBrainz disc id", itable.getMusicBrainzDiscId() url = itable.getAccurateRipURL() print "AccurateRip URL", url # FIXME: download url as a task too responses = [] import urllib2 try: handle = urllib2.urlopen(url) data = handle.read() responses = image.getAccurateRipResponses(data) except urllib2.HTTPError, e: if e.code == 404: print 'Album not found in AccurateRip database' else: raise