option to embed current album arts (closes #182)

This commit is contained in:
Lucas Duailibe 2013-03-17 22:52:51 -03:00
parent 7b2ff4ae9b
commit 0c53c0bc3f
2 changed files with 25 additions and 6 deletions

View file

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

View file

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