mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 02:52:33 +01:00
add copy_album_art_maxwidth config option to convert plugin
This commit is contained in:
parent
e58e04f0ab
commit
04c12a50ac
1 changed files with 30 additions and 9 deletions
|
|
@ -29,6 +29,7 @@ from beets import ui, util, plugins, config
|
|||
from beets.plugins import BeetsPlugin
|
||||
from beets.util.confit import ConfigTypeError
|
||||
from beets import art
|
||||
from beets.util.artresizer import ArtResizer
|
||||
|
||||
_fs_lock = threading.Lock()
|
||||
_temp_files = [] # Keep track of temporary transcoded files for deletion.
|
||||
|
|
@ -132,6 +133,7 @@ class ConvertPlugin(BeetsPlugin):
|
|||
u'paths': {},
|
||||
u'never_convert_lossy_files': False,
|
||||
u'copy_album_art': False,
|
||||
u'copy_album_art_maxwidth': 0,
|
||||
})
|
||||
self.import_stages = [self.auto_convert]
|
||||
|
||||
|
|
@ -305,8 +307,8 @@ class ConvertPlugin(BeetsPlugin):
|
|||
dest=converted, keepnew=False)
|
||||
|
||||
def copy_album_art(self, album, dest_dir, path_formats, pretend=False):
|
||||
"""Copies the associated cover art of the album. Album must have at
|
||||
least one track.
|
||||
"""Copies or converts the associated cover art of the album. Album must
|
||||
have at least one track.
|
||||
"""
|
||||
if not album or not album.artpath:
|
||||
return
|
||||
|
|
@ -336,14 +338,33 @@ class ConvertPlugin(BeetsPlugin):
|
|||
util.displayable_path(album.artpath))
|
||||
return
|
||||
|
||||
if pretend:
|
||||
self._log.info(u'cp {0} {1}',
|
||||
util.displayable_path(album.artpath),
|
||||
util.displayable_path(dest))
|
||||
resize = False
|
||||
maxwidth = None
|
||||
|
||||
if self.config['copy_album_art_maxwidth']:
|
||||
maxwidth = self.config['copy_album_art_maxwidth'].get(int)
|
||||
size = ArtResizer.shared.get_size(album.artpath)
|
||||
if size:
|
||||
resize = ArtResizer.shared.must_resize(size, maxwidth)
|
||||
|
||||
if resize:
|
||||
if pretend:
|
||||
self._log.info(u'resize_artwork {0} {1}',
|
||||
util.displayable_path(album.artpath),
|
||||
util.displayable_path(dest))
|
||||
else:
|
||||
self._log.info(u'Converting cover art to {0}',
|
||||
util.displayable_path(dest))
|
||||
ArtResizer.shared.resize(maxwidth, album.artpath, dest)
|
||||
else:
|
||||
self._log.info(u'Copying cover art to {0}',
|
||||
util.displayable_path(dest))
|
||||
util.copy(album.artpath, dest)
|
||||
if pretend:
|
||||
self._log.info(u'cp {0} {1}',
|
||||
util.displayable_path(album.artpath),
|
||||
util.displayable_path(dest))
|
||||
else:
|
||||
self._log.info(u'Copying cover art to {0}',
|
||||
util.displayable_path(dest))
|
||||
util.copy(album.artpath, dest)
|
||||
|
||||
def convert_func(self, lib, opts, args):
|
||||
if not opts.dest:
|
||||
|
|
|
|||
Loading…
Reference in a new issue