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
def testSufjan(self): path = (u'whipper/Sufjan Stevens - Illinois/02. Sufjan Stevens - ' 'The Black Hawk War, or, How to Demolish an Entire ' 'Civilization and Still Feel Good About Yourself in the ' 'Morning, or, We Apologize for the Inconvenience but ' 'You\'re Going to Have to Leave Now, or, "I Have Fought ' 'the Big Knives and Will Continue to Fight Them Until They ' 'Are Off Our Lands!".flac') shorter = common.shrinkPath(path) self.failUnless(os.path.splitext(path)[0].startswith( os.path.splitext(shorter)[0])) self.failIfEquals(path, shorter)
def testSufjan(self): path = (u'whipper/Sufjan Stevens - Illinois/02. Sufjan Stevens - ' 'The Black Hawk War, or, How to Demolish an Entire ' 'Civilization and Still Feel Good About Yourself in the ' 'Morning, or, We Apologize for the Inconvenience but ' 'You\'re Going to Have to Leave Now, or, "I Have Fought ' 'the Big Knives and Will Continue to Fight Them Until They ' 'Are Off Our Lands!".flac') shorter = common.shrinkPath(path) self.failUnless( os.path.splitext(path)[0].startswith(os.path.splitext(shorter)[0])) self.failIfEquals(path, shorter)
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