mirror of
https://github.com/beetbox/beets.git
synced 2025-12-23 17:13:30 +01:00
fetchart complains if no imaging backend available
The `enforce_ratio` and `minwidth` options depend on PIL or ImageMagick. Previously it silently fails. Now it will log a warning, and accept the image. Tests concerning these options are skipped when no imaging backend is available. Fix #1460
This commit is contained in:
parent
0377510522
commit
a82dee35cb
4 changed files with 26 additions and 0 deletions
|
|
@ -409,7 +409,16 @@ class FetchArtPlugin(plugins.BeetsPlugin):
|
|||
if not (self.enforce_ratio or self.minwidth):
|
||||
return True
|
||||
|
||||
# get_size returns None if no local imaging backend is available
|
||||
size = ArtResizer.shared.get_size(candidate)
|
||||
|
||||
if not size:
|
||||
self._log.warning(u'could not verify size of image: please see '
|
||||
u'documentation for dependencies. '
|
||||
u'The configuration options `minwidth` and '
|
||||
u'`enforce_ratio` may be violated.')
|
||||
return True
|
||||
|
||||
return size and size[0] >= self.minwidth and \
|
||||
(not self.enforce_ratio or size[0] == size[1])
|
||||
|
||||
|
|
@ -446,6 +455,7 @@ class FetchArtPlugin(plugins.BeetsPlugin):
|
|||
|
||||
if self.maxwidth and out:
|
||||
out = ArtResizer.shared.resize(self.maxwidth, out)
|
||||
|
||||
return out
|
||||
|
||||
def batch_fetch_art(self, lib, albums, force):
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ New features:
|
|||
or alternatively any list of attributes that should be favored.
|
||||
* The :doc:`/plugins/metasync` plugin now lets you get metadata from iTunes.
|
||||
This plugin is still in an experimental phase. :bug:`1450`
|
||||
* The :doc:`/plugins/fetchart` plugin will now complain for the `enforce_ratio`
|
||||
and `min_width` options if no local imaging backend is available. :bug:`1460`
|
||||
|
||||
|
||||
Fixes:
|
||||
|
|
|
|||
|
|
@ -54,6 +54,12 @@ file. The available options are:
|
|||
Default: ``coverart itunes albumart amazon google wikipedia``, i.e.,
|
||||
all sources.
|
||||
|
||||
Note: ``minwidth`` and ``enforce_ratio`` options require either `ImageMagick`_
|
||||
or `PIL`_.
|
||||
|
||||
.. _PIL: http://www.pythonware.com/products/pil/
|
||||
.. _ImageMagick: http://www.imagemagick.org/
|
||||
|
||||
Here's an example that makes plugin select only images that contain *front* or
|
||||
*back* keywords in their filenames and prioritizes the iTunes source over
|
||||
others::
|
||||
|
|
|
|||
|
|
@ -30,11 +30,15 @@ from beets import library
|
|||
from beets import importer
|
||||
from beets import config
|
||||
from beets import logging
|
||||
from beets.util.artresizer import ArtResizer, WEBPROXY
|
||||
|
||||
|
||||
logger = logging.getLogger('beets.test_art')
|
||||
|
||||
|
||||
ARTRESIZER_USES_FALLBACK_BACKEND = ArtResizer.shared.method[0] == WEBPROXY
|
||||
|
||||
|
||||
class UseThePlugin(_common.TestCase):
|
||||
def setUp(self):
|
||||
super(UseThePlugin, self).setUp()
|
||||
|
|
@ -408,11 +412,15 @@ class ArtForAlbumTest(UseThePlugin):
|
|||
else:
|
||||
self.assertIsNone(local_artpath)
|
||||
|
||||
@unittest.skipIf(ARTRESIZER_USES_FALLBACK_BACKEND,
|
||||
'ArtResizer has no local imaging backend available')
|
||||
def test_respect_minwidth(self):
|
||||
self.plugin.minwidth = 300
|
||||
self._assertImageIsValidArt(self.IMG_225x225, False)
|
||||
self._assertImageIsValidArt(self.IMG_348x348, True)
|
||||
|
||||
@unittest.skipIf(ARTRESIZER_USES_FALLBACK_BACKEND,
|
||||
'ArtResizer has no local imaging backend available')
|
||||
def test_respect_enforce_ratio_yes(self):
|
||||
self.plugin.enforce_ratio = True
|
||||
self._assertImageIsValidArt(self.IMG_500x490, False)
|
||||
|
|
|
|||
Loading…
Reference in a new issue