* morituri/common/program.py:
* morituri/rip/image.py: feature: add %r/%R for release type to track/disc template.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2012-12-22 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/common/program.py:
|
||||
* morituri/rip/image.py:
|
||||
feature: add %r/%R for release type to track/disc template.
|
||||
|
||||
2012-12-22 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/common/musicbrainzngs.py:
|
||||
|
||||
@@ -154,7 +154,7 @@ class Program(log.Loggable):
|
||||
assert type(outdir) is unicode, "%r is not unicode" % outdir
|
||||
assert type(template) is unicode, "%r is not unicode" % template
|
||||
|
||||
# the template is similar to grip, except for %s/%S
|
||||
# the template is similar to grip, except for %s/%S/%r/%R
|
||||
# see #gripswitches
|
||||
|
||||
# returns without extension
|
||||
@@ -165,7 +165,9 @@ class Program(log.Loggable):
|
||||
|
||||
# default values
|
||||
v['A'] = 'Unknown Artist'
|
||||
v['d'] = mbdiscid
|
||||
v['d'] = mbdiscid # fallback for title
|
||||
v['r'] = 'unknown'
|
||||
v['R'] = 'Unknown'
|
||||
|
||||
v['a'] = v['A']
|
||||
if i == 0:
|
||||
@@ -180,6 +182,8 @@ class Program(log.Loggable):
|
||||
v['A'] = filterForPath(self.metadata.artist)
|
||||
v['S'] = filterForPath(self.metadata.sortName)
|
||||
v['d'] = filterForPath(self.metadata.title)
|
||||
v['R'] = self.metadata.releaseType
|
||||
v['r'] = self.metadata.releaseType.lower()
|
||||
if i > 0:
|
||||
try:
|
||||
v['a'] = filterForPath(self.metadata.tracks[i - 1].artist)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
import os
|
||||
|
||||
from morituri.common import logcommand, accurip, program, encode
|
||||
from morituri.common import logcommand, accurip, program, encode, renamer
|
||||
from morituri.image import image
|
||||
from morituri.result import result
|
||||
|
||||
@@ -147,6 +147,56 @@ class Retag(logcommand.LogCommand):
|
||||
print '%s already tagged correctly' % path
|
||||
print
|
||||
|
||||
class Rename(logcommand.LogCommand):
|
||||
|
||||
summary = "rename image and all files based on metadata"
|
||||
|
||||
def addOptions(self):
|
||||
self.parser.add_option('-R', '--release-id',
|
||||
action="store", dest="release_id",
|
||||
help="MusicBrainz release id to match to (if there are multiple)")
|
||||
|
||||
|
||||
def do(self, args):
|
||||
prog = program.Program(stdout=self.stdout)
|
||||
runner = task.SyncRunner()
|
||||
|
||||
for arg in args:
|
||||
self.stdout.write('Renaming image %r\n' % arg)
|
||||
arg = arg.decode('utf-8')
|
||||
cueImage = image.Image(arg)
|
||||
cueImage.setup(runner)
|
||||
|
||||
mbdiscid = cueImage.table.getMusicBrainzDiscId()
|
||||
|
||||
operator = renamer.Operator(statePath, mbdiscid)
|
||||
|
||||
self.stdout.write('MusicBrainz disc id is %s\n' % mbdiscid)
|
||||
prog.metadata = prog.getMusicBrainz(cueImage.table, mbdiscid,
|
||||
release=self.options.release_id)
|
||||
|
||||
if not prog.metadata:
|
||||
print 'Not in MusicBrainz database, skipping'
|
||||
continue
|
||||
|
||||
# FIXME: this feels like we're poking at internals.
|
||||
prog.cuePath = arg
|
||||
prog.result = result.RipResult()
|
||||
for track in cueImage.table.tracks:
|
||||
path = cueImage.getRealPath(track.indexes[1].path)
|
||||
|
||||
taglist = prog.getTagList(track.number)
|
||||
self.debug(
|
||||
'possibly retagging %r from cue path %r with taglist %r',
|
||||
path, arg, taglist)
|
||||
t = encode.SafeRetagTask(path, taglist)
|
||||
runner.run(t)
|
||||
path = os.path.basename(path)
|
||||
if t.changed:
|
||||
print 'Retagged %s' % path
|
||||
else:
|
||||
print '%s already tagged correctly' % path
|
||||
print
|
||||
|
||||
class Verify(logcommand.LogCommand):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user