From 20e4f5d2098f2b76aaa1ec41e61e8f4e52da99d1 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Thu, 14 Jan 2016 18:08:22 -0200 Subject: [PATCH 1/2] Info plugin: add option to print only keys --- beetsplug/info.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/beetsplug/info.py b/beetsplug/info.py index 61f0c7971..e67527247 100644 --- a/beetsplug/info.py +++ b/beetsplug/info.py @@ -119,6 +119,24 @@ def print_data(data, item=None, fmt=None): ui.print_(lineformat.format(field, value)) +def print_data_keys(data, item=None): + + path = displayable_path(item.path) if item else None + formatted = [] + for key, value in data.iteritems(): + formatted.append(key) + + if len(formatted) == 0: + return + + line_format = u'{0}{{0}}'.format(u' ' * 4) + if path: + ui.print_(displayable_path(path)) + + for field in sorted(formatted): + ui.print_(line_format.format(field)) + + class InfoPlugin(BeetsPlugin): def commands(self): @@ -131,6 +149,8 @@ class InfoPlugin(BeetsPlugin): cmd.parser.add_option('-i', '--include-keys', default=[], action='append', dest='included_keys', help='comma separated list of keys to show') + cmd.parser.add_option('-k', '--keys-only', action='store_true', + help='show only the keys') cmd.parser.add_format_option(target='item') return [cmd] @@ -173,7 +193,10 @@ class InfoPlugin(BeetsPlugin): else: if not first: ui.print_() - print_data(data, item, opts.format) + if opts.keys_only: + print_data_keys(data, item) + else: + print_data(data, item, opts.format) first = False if opts.summarize: From f75b4b4e3b6b164234021381947b3b347a4152e1 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Fri, 15 Jan 2016 02:40:33 -0200 Subject: [PATCH 2/2] Update info docs --- docs/plugins/info.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins/info.rst b/docs/plugins/info.rst index b36e69051..238a957ff 100644 --- a/docs/plugins/info.rst +++ b/docs/plugins/info.rst @@ -39,7 +39,7 @@ Additional command-line options include: * ``--format`` or ``-f``: Specify a specific format with which to print every item. This uses the same template syntax as beets’ :doc:`path formats `. - +* ``--keys-only`` or ``-k``: Show the name of the tags without the values. .. _id3v2: http://id3v2.sourceforge.net .. _mp3info: http://www.ibiblio.org/mp3info/