This commit is contained in:
Adrian Sampson 2012-10-21 15:26:50 -07:00
commit 3fbce8dfdd
4 changed files with 13 additions and 26 deletions

View file

@ -814,7 +814,7 @@ def list_items(lib, query, album, fmt, config):
"""Print out items in lib matching query. If album, then search for
albums instead of single items.
"""
tmpl = Template(fmt) if fmt else None
tmpl = Template(fmt) if fmt else Template(ui._pick_format(config, album))
if album:
for album in lib.albums(query):
ui.print_obj(album, lib, config, tmpl)

View file

@ -103,9 +103,7 @@ def convert_func(lib, config, opts, args):
raise ui.UserError('no convert destination set')
threads = opts.threads if opts.threads is not None else conf['threads']
fmt = '$albumartist - $album' if opts.album \
else '$artist - $album - $title'
ui.commands.list_items(lib, ui.decargs(args), opts.album, False, fmt)
ui.commands.list_items(lib, ui.decargs(args), opts.album, None, config)
if not ui.input_yn("Convert? (Y/n)"):
return

View file

@ -16,7 +16,7 @@
"""
import beets
from beets.plugins import BeetsPlugin
from beets.ui import Subcommand, decargs, print_
from beets.ui import Subcommand, decargs, print_obj
from beets.util.functemplate import Template
import difflib
@ -47,19 +47,16 @@ def fuzzy_list(lib, config, opts, args):
query = ' '.join(query).lower()
queryMatcher = difflib.SequenceMatcher(b=query)
fmt = opts.format
if opts.threshold is not None:
threshold = float(opts.threshold)
else:
threshold = float(conf['threshold'])
if fmt is None:
# If no specific template is supplied, use a default
if opts.album:
fmt = u'$albumartist - $album'
else:
fmt = u'$artist - $album - $title'
template = Template(fmt)
if opts.path:
fmt = '$path'
else:
fmt = opts.format
template = Template(fmt) if fmt else None
if opts.album:
objs = lib.albums()
@ -68,13 +65,9 @@ def fuzzy_list(lib, config, opts, args):
items = filter(lambda i: is_match(queryMatcher, i, album=opts.album,
threshold=threshold), objs)
for i in items:
if opts.path:
print_(i.item_dir() if opts.album else i.path)
elif opts.album:
print_(i.evaluate_template(template))
else:
print_(i.evaluate_template(template, lib))
for item in items:
print_obj(item, lib, config, template)
if opts.verbose:
print(is_match(queryMatcher, i, album=opts.album, verbose=True)[1])

View file

@ -34,12 +34,8 @@ def random_item(lib, config, opts, args):
number = min(len(objs), opts.number)
objs = random.sample(objs, number)
if opts.album:
for album in objs:
print_obj(album, lib, config, template)
else:
for item in objs:
print_obj(item, lib, config, template)
for item in objs:
print_obj(item, lib, config, template)
random_cmd = Subcommand('random',
help='chose a random track or album')