embedart: Handle unparseable IM output (#1241)

This commit is contained in:
Adrian Sampson 2015-01-18 16:18:22 -08:00
parent dc5a79e35c
commit 909c96b060
2 changed files with 14 additions and 7 deletions

View file

@ -190,16 +190,22 @@ class EmbedCoverArtPlugin(BeetsPlugin):
stdout, stderr = proc.communicate()
if proc.returncode:
if proc.returncode != 1:
self._log.warn(u'IM phashes compare failed for {0}, '
u'{1}', displayable_path(imagepath),
displayable_path(art))
self._log.debug(u'IM phashes compare failed for {0}, '
u'{1}', displayable_path(imagepath),
displayable_path(art))
return
phashDiff = float(stderr)
out_str = stderr
else:
phashDiff = float(stdout)
out_str = stdout
self._log.info(u'compare PHASH score is {0}', phashDiff)
if phashDiff > compare_threshold:
try:
phash_diff = float(out_str)
except ValueError:
self._log.debug(u'IM output is not a number: {0!r}',
out_str)
self._log.info(u'compare PHASH score is {0}', phash_diff)
if phash_diff > compare_threshold:
return False
return True

View file

@ -30,6 +30,7 @@ Fixes:
* :doc:`/plugins/lastgenre`: Add classical music to the built-in whitelist and
canonicalization tree. :bug:`1239` :bug:`1240`
* Incremental imports now (once again) show a "skipped N directories" message.
* :doc:`/plugins/embedart`: Handle errors in ImageMagick's output. :bug:`1241`
For developers: