diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 4609f9f50..d98fc1328 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -86,12 +86,26 @@ class EmbedCoverArtPlugin(BeetsPlugin): help='extract an image from file metadata') extract_cmd.parser.add_option('-o', dest='outpath', help='image output file') + extract_cmd.parser.add_option('-a', dest='albums', action='store_true', + help='extract the art of all matching albums') def extract_func(lib, opts, args): - outpath = normpath(opts.outpath or config['art_filename'].get()) - for item in lib.items(decargs(args)): - if self.extract(outpath, item): + if opts.albums: + if opts.outpath and os.path.sep in normpath(opts.outpath): + self._log.error(u"When using -a, only specify a filename instead" + u" of a full path for -o") return + for album in lib.albums(decargs(args)): + outpath = normpath(os.path.join(album.path, opts.outpath + or config['art_filename'].get())) + for item in album.items(): + if self.extract(outpath, item): + return + else: + outpath = normpath(opts.outpath or config['art_filename'].get()) + for item in lib.items(decargs(args)): + if self.extract(outpath, item): + return extract_cmd.func = extract_func # Clear command. diff --git a/docs/plugins/embedart.rst b/docs/plugins/embedart.rst index 273046979..2c8748d14 100644 --- a/docs/plugins/embedart.rst +++ b/docs/plugins/embedart.rst @@ -84,5 +84,11 @@ embedded album art: ``art_filename`` configuration option. It defaults to ``cover`` if it's not specified via ``-o`` nor the config. +* ``beet extractart -a [-o FILE] QUERY``: extracts the images for all albums + matching the query. The images are placed inside the album folder. The + destination filename is taken either from the ``-o`` option or the + ``art_filename`` configuration option. It defaults to ``cover`` if it's not + specified. + * ``beet clearart QUERY``: removes all embedded images from all items matching the query. (Use with caution!)