diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 5fca4c367..a38daa0e7 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -71,11 +71,14 @@ class EmbedCoverArtPlugin(BeetsPlugin): # Embed command. embed_cmd = ui.Subcommand('embedart', help='embed an image file into file metadata') + embed_cmd.parser.add_option('-c', '--current', help='embed the current\ + album art into metadata', action='store_true') def embed_func(lib, opts, args): - if not args: - raise ui.UserError('specify an image file') - imagepath = normpath(args.pop(0)) - embed(lib, imagepath, decargs(args)) + if opts.current: + embed_current(lib, decargs(args)) + else: + imagepath = normpath(args.pop(0)) + embed(lib, imagepath, decargs(args)) embed_cmd.func = embed_func # Extract command. @@ -112,6 +115,20 @@ def embed(lib, imagepath, query): _embed(imagepath, album.items(), config['embedart']['maxwidth'].get(int)) + +def embed_current(lib, query): + albums = lib.albums(query) + for album in albums: + if not album.artpath: + log.info(u'No album art found: {0} - {1}'. + format(album.albumartist, album.album)) + continue + + log.info('Embedding album art into {0} - {1}'. + format(album.albumartist, album.album)) + _embed(album.artpath, album.items(), + config['embedart']['maxwidth'].get(int)) + # "extractart" command. def extract(lib, outpath, query): items = lib.items(query) diff --git a/docs/plugins/embedart.rst b/docs/plugins/embedart.rst index 9ce3f7257..b4dafcf3c 100644 --- a/docs/plugins/embedart.rst +++ b/docs/plugins/embedart.rst @@ -26,7 +26,9 @@ The ``embedart`` plugin provides a couple of commands for manually managing embedded album art: * ``beet embedart IMAGE QUERY``: given an image file and a query matching an - album, embed the image into the metadata of every track on the album. + album, embed the image into the metadata of every track on the album. Using + the ``-c`` or ``--current`` option and a query matching albums, the current + album art is embeded. * ``beet extractart [-o FILE] QUERY``: extracts the image from an item matching the query and stores it in a file. You can specify the destination file using @@ -40,7 +42,7 @@ embedded album art: Configuring ----------- -The ``auto`` option lets you disable automatic album art embedding. +The ``auto`` option lets you disable automatic album art embedding. To do so, add this to your ``config.yaml``:: embedart: