Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resuming previous rips #217

Merged
merged 1 commit into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions whipper/command/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ def doCommand(self):
else:
sys.stdout.write("output directory %s already exists\n" %
dirname.encode('utf-8'))
print("creating output directory %s" % dirname.encode('utf-8'))
os.makedirs(dirname)
else:
print("creating output directory %s" % dirname.encode('utf-8'))
os.makedirs(dirname)

# FIXME: turn this into a method

Expand Down
21 changes: 16 additions & 5 deletions whipper/common/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import binascii
import wave
import tempfile
import subprocess
import os


from whipper.extern.task import task as etask
Expand All @@ -34,16 +37,24 @@ class CRC32Task(etask.Task):
# TODO: Support sampleStart, sampleLength later on (should be trivial, just
# add change the read part in _crc32 to skip some samples and/or not
# read too far)
def __init__(self, path, sampleStart=0, sampleLength=-1):
def __init__(self, path, sampleStart=0, sampleLength=-1, is_wave=True):
self.path = path
self.is_wave = is_wave

def start(self, runner):
etask.Task.start(self, runner)
self.schedule(0.0, self._crc32)

def _crc32(self):
w = wave.open(self.path)
d = w._data_chunk.read()
fd, tmpf = tempfile.mkstemp()

self.checksum = binascii.crc32(d) & 0xffffffff
self.stop()
try:
subprocess.check_call(['flac', '-d', self.path, '-fo', tmpf])

w = wave.open(tmpf)
d = w._data_chunk.read()

self.checksum = binascii.crc32(d) & 0xffffffff
self.stop()
finally:
os.remove(tmpf)
4 changes: 2 additions & 2 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ def getHTOA(self):
return (start, stop)

def verifyTrack(self, runner, trackResult):

t = checksum.CRC32Task(trackResult.filename)
is_wave = not trackResult.filename.endswith('.flac')
t = checksum.CRC32Task(trackResult.filename, is_wave=is_wave)

try:
runner.run(t)
Expand Down