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