program.py: correct m3u htoa handling

This commit is contained in:
Samantha Baldwin
2017-09-10 21:53:08 -04:00
parent a482c86832
commit b98cc32fd0
2 changed files with 13 additions and 16 deletions

View File

@@ -464,14 +464,12 @@ Log files will log the path to tracks relative to this directory.
self.program.saveRipResult()
# check for hidden track one audio
htoapath = None
htoa = self.program.getHTOA()
if htoa:
start, stop = htoa
print('found Hidden Track One Audio from frame %d to %d' % (
start, stop))
_ripIfNotRipped(0)
htoapath = self.program.result.tracks[0].filename
for i, track in enumerate(self.itable.tracks):
# FIXME: rip data tracks differently
@@ -486,7 +484,7 @@ Log files will log the path to tracks relative to this directory.
self.program.writeCue(discName)
logger.debug('writing m3u file for %r', discName)
self.program.write_m3u(discName, htoapath)
self.program.write_m3u(discName)
if self.program.verifyImage(self.runner, self.ittoc, self.itable):
print('rip verified as accurate')

View File

@@ -597,28 +597,27 @@ class Program:
return False
return accurip.verify_result(self.result, responses, checksums)
def write_m3u(self, discname, htoapath):
def write_m3u(self, discname):
m3uPath = u'%s.m3u' % discname
with open(m3uPath, 'w') as f:
f.write(u'#EXTM3U\n')
for i, track in enumerate(self.result.tracks):
if not track.filename:
# false positive htoa
continue
if track.number == 0:
length = (self.result.table.getTrackStart(1) /
common.FRAMES_PER_SECOND)
else:
length = (self.result.table.getTrackLength(i) /
common.FRAMES_PER_SECOND)
def writeFile(path, length):
target_path = common.getRelativePath(path, m3uPath)
target_path = common.getRelativePath(track.filename, m3uPath)
u = u'#EXTINF:%d,%s\n' % (length, target_path)
f.write(u.encode('utf-8'))
u = '%s\n' % target_path
f.write(u.encode('utf-8'))
if htoapath:
writeFile(htoapath,
self.result.table.getTrackStart(1) /
common.FRAMES_PER_SECOND)
for i, track in enumerate(self.result.tracks):
writeFile(track.filename,
(self.result.table.getTrackLength(i + 1) /
common.FRAMES_PER_SECOND))
def writeCue(self, discName):
assert self.result.table.canCue()
cuePath = '%s.cue' % discName