* morituri/common/program.py:
Add a retagging command. Add a getMusicBrainz() method. * morituri/rip/cd.py: Use it. * morituri/image/image.py: Add a task to retag an image. * morituri/rip/image.py: Add a command to retag an image.
This commit is contained in:
@@ -113,26 +113,7 @@ See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=1
|
||||
mbdiscid = ittoc.getMusicBrainzDiscId()
|
||||
print "MusicBrainz disc id", mbdiscid
|
||||
|
||||
# look up disc on musicbrainz
|
||||
metadatas = None
|
||||
try:
|
||||
metadatas = program.musicbrainz(mbdiscid)
|
||||
except program.MusicBrainzException, e:
|
||||
print "Error:", e
|
||||
print 'Continuing without metadata'
|
||||
|
||||
if metadatas:
|
||||
print 'Matching releases:'
|
||||
for metadata in metadatas:
|
||||
print 'Artist : %s' % metadata.artist.encode('utf-8')
|
||||
print 'Title : %s' % metadata.title.encode('utf-8')
|
||||
|
||||
# Select one of the returned releases. We just pick the first one.
|
||||
prog.metadata = metadatas[0]
|
||||
else:
|
||||
print 'Submit this disc to MusicBrainz at:'
|
||||
print ittoc.getMusicBrainzSubmitURL()
|
||||
print
|
||||
prog.metadata = prog.getMusicBrainz(ittoc, mbdiscid)
|
||||
|
||||
# now, read the complete index table, which is slower
|
||||
itable = prog.getTable(runner, ittoc.getCDDBDiscId(), device)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
import os
|
||||
|
||||
from morituri.common import logcommand, task, accurip, program
|
||||
from morituri.common import logcommand, task, accurip, program, encode
|
||||
from morituri.image import image, cue
|
||||
from morituri.result import result
|
||||
from morituri.program import cdrdao, cdparanoia
|
||||
@@ -97,6 +97,32 @@ class Encode(logcommand.LogCommand):
|
||||
outm3u.write('%s' % root)
|
||||
outm3u.close()
|
||||
|
||||
class Retag(logcommand.LogCommand):
|
||||
summary = "retag image files"
|
||||
|
||||
def do(self, args):
|
||||
prog = program.Program()
|
||||
runner = task.SyncRunner()
|
||||
cache = accurip.AccuCache()
|
||||
|
||||
for arg in args:
|
||||
arg = unicode(arg)
|
||||
cueImage = image.Image(arg)
|
||||
cueImage.setup(runner)
|
||||
|
||||
mbdiscid = cueImage.table.getMusicBrainzDiscId()
|
||||
prog.metadata = prog.getMusicBrainz(cueImage.table, mbdiscid)
|
||||
|
||||
# FIXME: this feels like we're poking at internals.
|
||||
prog.cuePath = arg
|
||||
prog.result = result.RipResult()
|
||||
for track in cueImage.table.tracks:
|
||||
path = track.indexes[1].path
|
||||
taglist = prog.getTagList(track.number)
|
||||
self.debug('possibly retagging %r with taglist %r',
|
||||
path, taglist)
|
||||
runner.run(encode.SafeRetagTask(path, taglist))
|
||||
|
||||
class Verify(logcommand.LogCommand):
|
||||
summary = "verify image"
|
||||
|
||||
@@ -128,4 +154,4 @@ class Verify(logcommand.LogCommand):
|
||||
class Image(logcommand.LogCommand):
|
||||
summary = "handle images"
|
||||
|
||||
subCommandClasses = [Encode, Verify, ]
|
||||
subCommandClasses = [Encode, Retag, Verify, ]
|
||||
|
||||
Reference in New Issue
Block a user