Skip to content

Commit

Permalink
Merge pull request #1591 from jackwilsdon/embedart-remove-art-file
Browse files Browse the repository at this point in the history
Add `remove_art_file` configuration property to EmbedArt plugin
  • Loading branch information
sampsyo committed Sep 7, 2015
2 parents f8d9019 + 64e33b2 commit 8963d88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions beetsplug/embedart.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self):
'auto': True,
'compare_threshold': 0,
'ifempty': False,
'remove_art_file': False
})

if self.config['maxwidth'].get(int) and not ArtResizer.shared.local:
Expand All @@ -62,6 +63,7 @@ def commands(self):
maxwidth = self.config['maxwidth'].get(int)
compare_threshold = self.config['compare_threshold'].get(int)
ifempty = self.config['ifempty'].get(bool)
remove_art_file = self.config['remove_art_file'].get(bool)

def embed_func(lib, opts, args):
if opts.file:
Expand All @@ -78,6 +80,14 @@ def embed_func(lib, opts, args):
art.embed_album(self._log, album, maxwidth, False,
compare_threshold, ifempty)

if remove_art_file and album.artpath is not None:
if os.path.isfile(album.artpath):
self._log.debug(u'Removing album art file '
u'for {0}', album)
os.remove(album.artpath)
album.artpath = None
album.store()

embed_cmd.func = embed_func

# Extract command.
Expand Down
6 changes: 6 additions & 0 deletions docs/plugins/embedart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ file. The available options are:
the aspect ratio is preserved. See also :ref:`image-resizing` for further
caveats about image resizing.
Default: 0 (disabled).
- **remove_art_file**: Automatically remove the album art file for the album
after it has been embedded. This option is best used alongside the
:doc:`FetchArt </plugins/fetchart>` plugin to download art with the purpose of
directly embedding it into the file's metadata without an "intermediate"
album art file.
Default: ``no``.

Note: ``compare_threshold`` option requires `ImageMagick`_, and ``maxwidth``
requires either `ImageMagick`_ or `PIL`_.
Expand Down

0 comments on commit 8963d88

Please sign in to comment.