* morituri/program/cdparanoia.py:

* morituri/rip/cd.py:
	  Handle another off-by-one error in the m3u handling.
	  Add a getTagList function.
	  Use it to encode tags.
This commit is contained in:
Thomas Vander Stichele
2009-06-01 12:53:14 +00:00
parent 0f7f60e1b1
commit 2b17b8e912
3 changed files with 66 additions and 5 deletions

View File

@@ -1,3 +1,11 @@
2009-06-01 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/program/cdparanoia.py:
* morituri/rip/cd.py:
Handle another off-by-one error in the m3u handling.
Add a getTagList function.
Use it to encode tags.
2009-06-01 Thomas Vander Stichele <thomas at apestaart dot org> 2009-06-01 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/encode.py: * morituri/common/encode.py:

View File

@@ -234,7 +234,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
_tmpwavpath = None _tmpwavpath = None
_tmppath = None _tmppath = None
def __init__(self, path, table, start, stop, offset=0, device=None, profile=None): def __init__(self, path, table, start, stop, offset=0, device=None, profile=None, taglist=None):
""" """
@param path: where to store the ripped track @param path: where to store the ripped track
@type path: str @type path: str
@@ -250,11 +250,15 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
@type device: str @type device: str
@param profile: the encoding profile @param profile: the encoding profile
@type profile: L{encode.Profile} @type profile: L{encode.Profile}
@param taglist: a list of tags
@param taglist: L{gst.TagList}
""" """
task.MultiSeparateTask.__init__(self) task.MultiSeparateTask.__init__(self)
self.path = path self.path = path
if taglist:
self.debug('read and verify with taglist %r', taglist)
# FIXME: choose a dir on the same disk/dir as the final path # FIXME: choose a dir on the same disk/dir as the final path
fd, tmppath = tempfile.mkstemp(suffix='.morituri.wav') fd, tmppath = tempfile.mkstemp(suffix='.morituri.wav')
os.close(fd) os.close(fd)
@@ -273,7 +277,8 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
profile.extension) profile.extension)
os.close(fd) os.close(fd)
self._tmppath = tmpoutpath self._tmppath = tmpoutpath
self.tasks.append(encode.EncodeTask(tmppath, tmpoutpath, profile)) self.tasks.append(encode.EncodeTask(tmppath, tmpoutpath, profile,
taglist=taglist))
# make sure our encoding is accurate # make sure our encoding is accurate
self.tasks.append(checksum.CRC32Task(tmpoutpath)) self.tasks.append(checksum.CRC32Task(tmpoutpath))

View File

@@ -27,6 +27,8 @@ import math
import gobject import gobject
gobject.threads_init() gobject.threads_init()
import gst
from morituri.common import logcommand, task, checksum, common, accurip from morituri.common import logcommand, task, checksum, common, accurip
from morituri.common import drive, encode from morituri.common import drive, encode
from morituri.image import image, cue, table from morituri.image import image, cue, table
@@ -168,6 +170,49 @@ def getPath(outdir, template, metadata, i):
return os.path.join(outdir, template % v) return os.path.join(outdir, template % v)
def getTagList(metadata, i):
"""
Based on the metadata, get a gst.TagList for the given track.
@param metadata:
@type metadata: L{DiscMetadata}
@param i: track number (0 for HTOA)
@type i: int
@rtype: L{gst.TagList}
"""
artist = u'Unknown Artist'
disc = u'Unknown Disc'
title = u'Unknown Track'
if metadata:
artist = metadata.artist
disc = metadata.title
if i > 0:
try:
artist = metadata.tracks[i - 1].artist
title = metadata.tracks[i - 1].title
except IndexError, e:
print 'ERROR: no track %d found, %r' % (i, e)
raise
else:
# htoa defaults to disc's artist
title = 'Hidden Track One Audio'
ret = gst.TagList()
# gst-python 0.10.15.1 does not handle unicode -> utf8 string conversion
# see http://bugzilla.gnome.org/show_bug.cgi?id=584445
ret[gst.TAG_ARTIST] = artist.encode('utf-8')
ret[gst.TAG_TITLE] = title.encode('utf-8')
ret[gst.TAG_ALBUM] = disc.encode('utf-8')
ret[gst.TAG_TRACK_NUMBER] = i
ret[gst.TAG_TRACK_COUNT] = len(metadata.tracks)
# FIXME: gst.TAG_ISRC
return ret
class Rip(logcommand.LogCommand): class Rip(logcommand.LogCommand):
summary = "rip CD" summary = "rip CD"
@@ -286,7 +331,8 @@ class Rip(logcommand.LogCommand):
start, stop - 1, start, stop - 1,
offset=int(self.options.offset), offset=int(self.options.offset),
device=self.parentCommand.options.device, device=self.parentCommand.options.device,
profile=profile) profile=profile,
taglist=getTagList(metadata, 0))
function(runner, t) function(runner, t)
if t.checksum is not None: if t.checksum is not None:
@@ -321,7 +367,8 @@ class Rip(logcommand.LogCommand):
ittoc.getTrackEnd(i + 1), ittoc.getTrackEnd(i + 1),
offset=int(self.options.offset), offset=int(self.options.offset),
device=self.parentCommand.options.device, device=self.parentCommand.options.device,
profile=profile) profile=profile,
taglist=getTagList(metadata, i))
t.description = 'Reading Track %d' % (i + 1) t.description = 'Reading Track %d' % (i + 1)
function(runner, t) function(runner, t)
if t.checksum: if t.checksum:
@@ -358,7 +405,8 @@ class Rip(logcommand.LogCommand):
handle.write('%s\n' % os.path.basename(htoapath)) handle.write('%s\n' % os.path.basename(htoapath))
for i, track in enumerate(itable.tracks): for i, track in enumerate(itable.tracks):
path = getPath(outdir, self.options.track_template, metadata, i) + '.' + extension path = getPath(outdir, self.options.track_template, metadata,
i + 1) + '.' + extension
handle.write('#EXTINF:%d,%s\n' % ( handle.write('#EXTINF:%d,%s\n' % (
itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND, itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND,
os.path.basename(path))) os.path.basename(path)))