From 54f29812cf321aef2934ba5fd352d6770fcf5d09 Mon Sep 17 00:00:00 2001 From: Jakob Schnitzer Date: Sun, 21 Oct 2012 13:35:41 +0200 Subject: [PATCH 1/4] convert: fix breakage due to recent API changes --- beetsplug/convert.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index fecaa9fa0..0c4ee7ead 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -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 From d6f20e91bd1667e2eced38ae825ce9bad0bf1d44 Mon Sep 17 00:00:00 2001 From: Jakob Schnitzer Date: Sun, 21 Oct 2012 13:54:24 +0200 Subject: [PATCH 2/4] Speedup 'beet ls' if no format is specified --- beets/ui/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 81e1dc553..24d7280e7 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -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) From e80dce6930c5ca2a75005fa434c0352523508ef3 Mon Sep 17 00:00:00 2001 From: Philippe Mongeau Date: Sun, 21 Oct 2012 11:29:21 -0400 Subject: [PATCH 3/4] fuzzy: use the new print_obj function --- beetsplug/fuzzy_search.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/beetsplug/fuzzy_search.py b/beetsplug/fuzzy_search.py index 398a78811..37a664ac7 100644 --- a/beetsplug/fuzzy_search.py +++ b/beetsplug/fuzzy_search.py @@ -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]) From 78f2003eb015b2ec1b45b695339a0ae28bf08edc Mon Sep 17 00:00:00 2001 From: Philippe Mongeau Date: Sun, 21 Oct 2012 11:39:23 -0400 Subject: [PATCH 4/4] simplify the random print code We don't need the 'if opts.album' since we print with the same function and argsuments. --- beetsplug/rdm.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/beetsplug/rdm.py b/beetsplug/rdm.py index 72b338138..6eebba0bd 100644 --- a/beetsplug/rdm.py +++ b/beetsplug/rdm.py @@ -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')