示例#1
0
文件: debug.py 项目: sqozz/whipper
    def do(self):
        from whipper.common import encode

        try:
            fromPath = unicode(self.options.input)
        except IndexError:
            # unexercised after BaseCommand
            sys.stdout.write('Please specify an input file.\n')
            return 3

        try:
            toPath = unicode(self.options.output)
        except IndexError:
            toPath = fromPath + '.flac'

        runner = task.SyncRunner()

        logger.debug('Encoding %s to %s', fromPath.encode('utf-8'),
                     toPath.encode('utf-8'))
        encodetask = encode.FlacEncodeTask(fromPath, toPath)

        runner.run(encodetask)

        # I think we want this to be
        # fromPath, not toPath, since the sox peak task, afaik, works on wave
        # files
        peaktask = encode.SoxPeakTask(fromPath)
        runner.run(peaktask)

        sys.stdout.write('Peak level: %r\n' % peaktask.peak)
        sys.stdout.write('Encoded to %s\n' % toPath.encode('utf-8'))
示例#2
0
文件: image.py 项目: spvkgn/whipper
        def add(index):

            path = image.getRealPath(index.path)
            assert isinstance(path, unicode), "%r is not unicode" % path
            logger.debug('schedule encode of %r', path)
            root, _ = os.path.splitext(os.path.basename(path))
            outpath = os.path.join(outdir, root + '.' + 'flac')
            logger.debug('schedule encode to %r', outpath)
            taskk = encode.FlacEncodeTask(
                path, os.path.join(outdir, root + '.' + 'flac'))
            self.addTask(taskk)
示例#3
0
    def __init__(self,
                 path,
                 table,
                 start,
                 stop,
                 overread,
                 offset=0,
                 device=None,
                 taglist=None,
                 what="track"):
        task.MultiSeparateTask.__init__(self)

        logger.debug('Creating read and verify task on %r', path)

        if taglist:
            logger.debug('read and verify with taglist %r', taglist)
        # FIXME: choose a dir on the same disk/dir as the final path
        fd, tmppath = tempfile.mkstemp(suffix='.whipper.wav')
        tmppath = unicode(tmppath)
        os.close(fd)
        self._tmpwavpath = tmppath

        from whipper.common import checksum

        self.tasks = []
        self.tasks.append(
            ReadTrackTask(tmppath,
                          table,
                          start,
                          stop,
                          overread,
                          offset=offset,
                          device=device,
                          what=what))
        self.tasks.append(checksum.CRC32Task(tmppath))
        t = ReadTrackTask(tmppath,
                          table,
                          start,
                          stop,
                          overread,
                          offset=offset,
                          device=device,
                          action="Verifying",
                          what=what)
        self.tasks.append(t)
        self.tasks.append(checksum.CRC32Task(tmppath))

        # encode to the final path + '.part'
        try:
            tmpoutpath = path + u'.part'
            open(tmpoutpath, 'wb').close()
        except IOError as e:
            if errno.ENAMETOOLONG != e.errno:
                raise
            path = common.shrinkPath(path)
            tmpoutpath = path + u'.part'
            open(tmpoutpath, 'wb').close()
        self._tmppath = tmpoutpath
        self.path = path

        from whipper.common import encode

        self.tasks.append(encode.FlacEncodeTask(tmppath, tmpoutpath))

        # MerlijnWajer: XXX: We run the CRC32Task on the wav file, because it's
        # in general stupid to run the CRC32 on the flac file since it already
        # has --verify. We should just get rid of this CRC32 step.
        # make sure our encoding is accurate
        self.tasks.append(checksum.CRC32Task(tmppath))
        self.tasks.append(encode.SoxPeakTask(tmppath))

        # TODO: Move tagging outside of cdparanoia
        self.tasks.append(encode.TaggingTask(tmpoutpath, taglist))

        self.checksum = None
示例#4
0
    def __init__(self,
                 path,
                 table,
                 start,
                 stop,
                 overread,
                 offset=0,
                 device=None,
                 taglist=None,
                 what="track",
                 coverArtPath=None):
        """
        Init ReadVerifyTrackTask.

        :param path: where to store the ripped track
        :type path: str
        :param table: table of contents of CD
        :type table: table.Table
        :param start: first frame to rip
        :type start: int
        :param stop: last frame to rip (inclusive)
        :type stop: int
        :param offset: read offset, in samples
        :type offset: int
        :param device: the device to rip from
        :type device: str
        :param taglist: a dict of tags
        :type taglist: dict
        """
        task.MultiSeparateTask.__init__(self)

        logger.debug('creating read and verify task on %r', path)

        if taglist:
            logger.debug('read and verify with taglist %r', taglist)
        # FIXME: choose a dir on the same disk/dir as the final path
        fd, tmppath = tempfile.mkstemp(suffix='.whipper.wav')
        os.fchmod(fd, 0o644)
        os.close(fd)
        self._tmpwavpath = tmppath

        from whipper.common import checksum

        self.tasks = []
        self.tasks.append(
            ReadTrackTask(tmppath,
                          table,
                          start,
                          stop,
                          overread,
                          offset=offset,
                          device=device,
                          what=what))
        self.tasks.append(checksum.CRC32Task(tmppath))
        t = ReadTrackTask(tmppath,
                          table,
                          start,
                          stop,
                          overread,
                          offset=offset,
                          device=device,
                          action="Verifying",
                          what=what)
        self.tasks.append(t)
        self.tasks.append(checksum.CRC32Task(tmppath))

        # encode to the final path + '.part'
        try:
            tmpoutpath = path + '.part'
            open(tmpoutpath, 'wb').close()
        except IOError as e:
            if errno.ENAMETOOLONG != e.errno:
                raise
            path = common.truncate_filename(common.shrinkPath(path))
            tmpoutpath = common.truncate_filename(path + '.part')
            open(tmpoutpath, 'wb').close()
        self._tmppath = tmpoutpath
        self.path = path

        from whipper.common import encode

        self.tasks.append(encode.FlacEncodeTask(tmppath, tmpoutpath))

        # MerlijnWajer: XXX: We run the CRC32Task on the wav file, because it's
        # in general stupid to run the CRC32 on the flac file since it already
        # has --verify. We should just get rid of this CRC32 step.
        # make sure our encoding is accurate
        self.tasks.append(checksum.CRC32Task(tmppath))
        self.tasks.append(encode.SoxPeakTask(tmppath))

        # TODO: Move tagging and embed picture outside of cdparanoia
        self.tasks.append(encode.TaggingTask(tmpoutpath, taglist))
        self.tasks.append(encode.EmbedPictureTask(tmpoutpath, coverArtPath))

        self.checksum = None