Latest artwork changes not working so well

Revisit later
This commit is contained in:
Ade
2017-03-16 07:55:27 +13:00
parent 519fdc3015
commit f877caff06
2 changed files with 23 additions and 20 deletions

View File

@@ -980,8 +980,8 @@
<div id="album_art_size_options" style="padding-left: 20px">
<div class="row">
Album art min width <input type="text" class="override-float" name="album_art_min_width" value="${config['album_art_min_width']}" size="4" title="Only images with a pixel width greater or equal are considered as valid album art candidates. Default: 0.">\
Album art max width <input type="text" class="override-float" name="album_art_max_width" value="${config['album_art_max_width']}" size="4" title="A maximum image width to downscale fetched images if they are too big.">
<!--Album art min width <input type="text" class="override-float" name="album_art_min_width" value="${config['album_art_min_width']}" size="4" title="Only images with a pixel width greater or equal are considered as valid album art candidates. Default: 0.">\-->
<!--Album art max width <input type="text" class="override-float" name="album_art_max_width" value="${config['album_art_max_width']}" size="4" title="A maximum image width to downscale fetched images if they are too big.">-->
</div>
</div>

View File

@@ -128,27 +128,30 @@ def getartwork(artwork_path):
# Check image and size
if artwork:
img_type, img_width, img_height = getImageInfo(artwork)
if not img_type or minwidth and img_width < minwidth:
logger.info("Artwork is not suitable or too small. Type: %s. Width: %s. Height: %s",
img_type, img_width, img_height)
artwork = None
elif maxwidth and img_width > maxwidth:
useproxy = True
else:
# Get rest of artwork
for chunk in data:
artwork += chunk
#TODO not working well
#img_type, img_width, img_height = getImageInfo(artwork)
#if not img_type or minwidth and img_width < minwidth:
# logger.info("Artwork is not suitable or too small. Type: %s. Width: %s. Height: %s",
# img_type, img_width, img_height)
# artwork = None
#elif maxwidth and img_width > maxwidth:
# useproxy = True
#else:
# Get rest of artwork
for chunk in data:
artwork += chunk
# Downsize using proxy service to max width
if useproxy:
logger.info("Artwork is greater than the maximum width, downsizing using proxy service")
artwork_path = '{0}?{1}'.format('http://images.weserv.nl/', urlencode({
'url': artwork_path.replace('http://', ''),
'w': maxwidth,
}))
artwork = request.request_content(artwork_path, timeout=20)
# if useproxy:
# logger.info("Artwork is greater than the maximum width, downsizing using proxy service")
# artwork_path = '{0}?{1}'.format('http://images.weserv.nl/', urlencode({
# 'url': artwork_path.replace('http://', ''),
# 'w': maxwidth,
# }))
# artwork = request.request_content(artwork_path, timeout=20)
return artwork