Add "beet export --album" (matching "beet info --album")

This commit is contained in:
Tianon Gravi 2021-10-27 08:55:36 -07:00
parent 89a7cc3701
commit 7bd36ed6ca
3 changed files with 17 additions and 3 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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.