[SCM] morituri/master: * 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.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:09:05 UTC 2014
The following commit has been merged in the master branch:
commit 2b17b8e912e6f003f2862675ec63f2e2eba5048c
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Mon Jun 1 12:53:14 2009 +0000
* 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.
diff --git a/ChangeLog b/ChangeLog
index 2cc186c..c0bb788 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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>
+
* morituri/common/encode.py:
* morituri/program/cdparanoia.py:
* morituri/rip/cd.py:
diff --git a/morituri/program/cdparanoia.py b/morituri/program/cdparanoia.py
index b5726a1..b6601df 100644
--- a/morituri/program/cdparanoia.py
+++ b/morituri/program/cdparanoia.py
@@ -234,7 +234,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
_tmpwavpath = 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
@type path: str
@@ -250,11 +250,15 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
@type device: str
@param profile: the encoding profile
@type profile: L{encode.Profile}
+ @param taglist: a list of tags
+ @param taglist: L{gst.TagList}
"""
task.MultiSeparateTask.__init__(self)
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
fd, tmppath = tempfile.mkstemp(suffix='.morituri.wav')
os.close(fd)
@@ -273,7 +277,8 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
profile.extension)
os.close(fd)
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
self.tasks.append(checksum.CRC32Task(tmpoutpath))
diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py
index 1029b92..6b749d5 100644
--- a/morituri/rip/cd.py
+++ b/morituri/rip/cd.py
@@ -27,6 +27,8 @@ import math
import gobject
gobject.threads_init()
+import gst
+
from morituri.common import logcommand, task, checksum, common, accurip
from morituri.common import drive, encode
from morituri.image import image, cue, table
@@ -168,6 +170,49 @@ def getPath(outdir, template, metadata, i):
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):
summary = "rip CD"
@@ -286,7 +331,8 @@ class Rip(logcommand.LogCommand):
start, stop - 1,
offset=int(self.options.offset),
device=self.parentCommand.options.device,
- profile=profile)
+ profile=profile,
+ taglist=getTagList(metadata, 0))
function(runner, t)
if t.checksum is not None:
@@ -321,7 +367,8 @@ class Rip(logcommand.LogCommand):
ittoc.getTrackEnd(i + 1),
offset=int(self.options.offset),
device=self.parentCommand.options.device,
- profile=profile)
+ profile=profile,
+ taglist=getTagList(metadata, i))
t.description = 'Reading Track %d' % (i + 1)
function(runner, t)
if t.checksum:
@@ -358,7 +405,8 @@ class Rip(logcommand.LogCommand):
handle.write('%s\n' % os.path.basename(htoapath))
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' % (
itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND,
os.path.basename(path)))
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list