From 7bd36ed6ca0b4dcc5f08a23b3f45ef791475f3b7 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 27 Oct 2021 08:55:36 -0700 Subject: [PATCH] Add "beet export --album" (matching "beet info --album") --- beetsplug/export.py | 16 +++++++++++++--- docs/changelog.rst | 1 + docs/plugins/export.rst | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/beetsplug/export.py b/beetsplug/export.py index 3cb8f8c4f..0d7049054 100644 --- a/beetsplug/export.py +++ b/beetsplug/export.py @@ -87,6 +87,10 @@ class ExportPlugin(BeetsPlugin): '-l', '--library', action='store_true', help='show library fields instead of tags', ) + cmd.parser.add_option( + '-a', '--album', action='store_true', + help='show album fields instead of tracks (implies "--library")', + ) cmd.parser.add_option( '--append', action='store_true', default=False, help='if should append data to the file', @@ -121,14 +125,20 @@ class ExportPlugin(BeetsPlugin): } ) - items = [] - data_collector = library_data if opts.library else tag_data + if opts.library or opts.album: + data_collector = library_data + else: + data_collector = tag_data included_keys = [] for keys in opts.included_keys: included_keys.extend(keys.split(',')) - for data_emitter in data_collector(lib, ui.decargs(args)): + items = [] + for data_emitter in data_collector( + lib, ui.decargs(args), + album=opts.album, + ): try: data, item = data_emitter(included_keys or '*') except (mediafile.UnreadableFileError, OSError) as ex: diff --git a/docs/changelog.rst b/docs/changelog.rst index b0234023a..14908da77 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -36,6 +36,7 @@ Other new things: * :doc:`/plugins/unimported`: Support excluding specific subdirectories in library. * :doc:`/plugins/info`: Support ``--album`` flag. +* :doc:`/plugins/export`: Support ``--album`` flag. Bug fixes: diff --git a/docs/plugins/export.rst b/docs/plugins/export.rst index 284d2b8b6..bca9d1e5a 100644 --- a/docs/plugins/export.rst +++ b/docs/plugins/export.rst @@ -34,6 +34,9 @@ The ``export`` command has these command-line options: * ``--library`` or ``-l``: Show data from the library database instead of the files' tags. +* ``--album`` or ``-a``: Show data from albums instead of tracks (implies + ``--library``). + * ``--output`` or ``-o``: Path for an output file. If not informed, will print the data in the console.