Esempio n. 1
0
    def _arcs(self, runner, table, track, offset):
        # rips the track with the given offset, return the arcs checksums
        logger.debug('ripping track %r with offset %d...', track, offset)

        fd, path = tempfile.mkstemp(suffix=u'.track%02d.offset%d.whipper.wav' %
                                    (track, offset))
        os.close(fd)

        t = cdparanoia.ReadTrackTask(path,
                                     table,
                                     table.getTrackStart(track),
                                     table.getTrackEnd(track),
                                     overread=False,
                                     offset=offset,
                                     device=self.options.device)
        t.description = 'Ripping track %d with read offset %d' % (track,
                                                                  offset)
        runner.run(t)

        v1 = arc.accuraterip_checksum(path,
                                      track,
                                      len(table.tracks),
                                      wave=True,
                                      v2=False)
        v2 = arc.accuraterip_checksum(path,
                                      track,
                                      len(table.tracks),
                                      wave=True,
                                      v2=True)

        os.unlink(path)
        return ("%08x" % v1, "%08x" % v2)
Esempio n. 2
0
def calculate_checksums(track_paths):
    """
    Return ARv1 and ARv2 checksums as two arrays of character strings in a
    dictionary: {'v1': ['deadbeef', ...], 'v2': [...]}

    Return None instead of checksum string for unchecksummable tracks.

    HTOA checksums are not included in the database and are not calculated.
    """
    track_count = len(track_paths)
    v1_checksums = []
    v2_checksums = []
    logger.debug('checksumming %d tracks', track_count)
    # This is done sequentially because it is very fast.
    for i, path in enumerate(track_paths):
        v1_sum = accuraterip_checksum(
            path, i+1, track_count, wave=True, v2=False
        )
        if not v1_sum:
            logger.error('could not calculate AccurateRip v1 checksum '
                         'for track %d %r', i + 1, path)
            v1_checksums.append(None)
        else:
            v1_checksums.append("%08x" % v1_sum)
        v2_sum = accuraterip_checksum(
            path, i+1, track_count, wave=True, v2=True
        )
        if not v2_sum:
            logger.error('could not calculate AccurateRip v2 checksum '
                         'for track %d %r', i + 1, path)
            v2_checksums.append(None)
        else:
            v2_checksums.append("%08x" % v2_sum)
    return {'v1': v1_checksums, 'v2': v2_checksums}
Esempio n. 3
0
    def _arcs(self, runner, table, track, offset):
        # rips the track with the given offset, return the arcs checksums
        logger.debug('Ripping track %r with offset %d ...', track, offset)

        fd, path = tempfile.mkstemp(
            suffix=u'.track%02d.offset%d.whipper.wav' % (
                track, offset))
        os.close(fd)

        t = cdparanoia.ReadTrackTask(path, table,
                                     table.getTrackStart(
                                         track), table.getTrackEnd(track),
                                     overread=False, offset=offset,
                                     device=self.options.device)
        t.description = 'Ripping track %d with read offset %d' % (
            track, offset)
        runner.run(t)

        v1 = arc.accuraterip_checksum(
                path, track, len(table.tracks), wave=True, v2=False
            )
        v2 = arc.accuraterip_checksum(
                path, track, len(table.tracks), wave=True, v2=True
            )

        os.unlink(path)
        return ("%08x" % v1, "%08x" % v2)
Esempio n. 4
0
def calculate_checksums(track_paths):
    """
    Calculate AccurateRip checksums for the given tracks.

    HTOA checksums are not included in the database and are not calculated.

    :returns: ARv1 and ARv2 checksums as two arrays of character strings in a
              dictionary: ``{'v1': ['deadbeef', ...], 'v2': [...]}``
              or None instead of checksum string for unchecksummable tracks.
    :rtype: dict(string, list()) or None
    """
    track_count = len(track_paths)
    v1_checksums = []
    v2_checksums = []
    logger.debug('checksumming %d tracks', track_count)
    # This is done sequentially because it is very fast.
    for i, path in enumerate(track_paths):
        if os.path.exists(path):
            v1_sum, v2_sum = accuraterip_checksum(path, i+1, track_count)
        else:
            logger.warning('Can\'t checksum %s; path doesn\'t exist', path)
            v1_sum, v2_sum = None, None
        if v1_sum is None:
            logger.error('could not calculate AccurateRip v1 checksum '
                         'for track %d %r', i + 1, path)
            v1_checksums.append(None)
        else:
            v1_checksums.append("%08x" % v1_sum)
        if v2_sum is None:
            logger.error('could not calculate AccurateRip v2 checksum '
                         'for track %d %r', i + 1, path)
            v2_checksums.append(None)
        else:
            v2_checksums.append("%08x" % v2_sum)
    return {'v1': v1_checksums, 'v2': v2_checksums}
Esempio n. 5
0
def calculate_checksums(track_paths):
    """
    Return ARv1 and ARv2 checksums as two arrays of character strings in a
    dictionary: {'v1': ['deadbeef', ...], 'v2': [...]}

    Return None instead of checksum string for unchecksummable tracks.

    HTOA checksums are not included in the database and are not calculated.
    """
    track_count = len(track_paths)
    v1_checksums = []
    v2_checksums = []
    logger.debug('checksumming %d tracks', track_count)
    # This is done sequentially because it is very fast.
    for i, path in enumerate(track_paths):
        v1_sum, v2_sum = accuraterip_checksum(path, i + 1, track_count)
        if v1_sum is None:
            logger.error(
                'could not calculate AccurateRip v1 checksum '
                'for track %d %r', i + 1, path)
            v1_checksums.append(None)
        else:
            v1_checksums.append("%08x" % v1_sum)
        if v2_sum is None:
            logger.error(
                'could not calculate AccurateRip v2 checksum '
                'for track %d %r', i + 1, path)
            v2_checksums.append(None)
        else:
            v2_checksums.append("%08x" % v2_sum)
    return {'v1': v1_checksums, 'v2': v2_checksums}
Esempio n. 6
0
    def _arc(self):
        arc = accuraterip_checksum(self.path, self.trackNumber,
                                   self.trackCount,
                                   self._wave, self._v2)
        self.checksum = arc

        self.stop()
Esempio n. 7
0
    def _arc(self):
        arc = accuraterip_checksum(self.path, self.trackNumber, self.trackCount,
                self._wave, self._v2)
        self.checksum = arc

        self.stop()