bcolors.NONE, ' * Amazon score:\t%s \t %s' % (amz_score, amz_image.URL.pyval)) if amz_score > best_score: front_uri = amz_image.URL.pyval best_score = amz_score # Evaluate Spotify if spotify is not None and release[ 'barcode'] is not None and release['barcode'] != "": albums = spotify.search_albums('upc:%s' % release['barcode']) if len(albums) == 1: colored_out( bcolors.WARNING, ' * Spotify = https://embed.spotify.com/?uri=%s&view=coverart' % (albums[0]['href'], )) image_url = spotify.artwork_url(albums[0]['href']) if image_url is not None: try: img_file = urllib2.urlopen(image_url) im = Image.open(StringIO(img_file.read())) spotify_score = im.size[0] * im.size[1] colored_out( bcolors.NONE, ' * Spotify score:\t%s \t %s' % (spotify_score, image_url)) if spotify_score > best_score: front_uri = image_url best_score = spotify_score except urllib2.HTTPError, e: pass # Evaluate iTunes
and re.sub(r'^(0+)', '', amz_barcode) != re.sub(r'^(0+)', '', release['barcode']): colored_out(bcolors.FAIL, " * Amz barcode doesn't match MB barcode (%s vs %s) => skipping" % (amz_barcode, release['barcode'])) continue if amz_image is not None: amz_score = amz_image.Height * amz_image.Width colored_out(bcolors.NONE, ' * Amazon score:\t%s \t %s' % (amz_score, amz_image.URL.pyval)) if amz_score > best_score: front_uri = amz_image.URL.pyval best_score = amz_score # Evaluate Spotify if spotify is not None and release['barcode'] is not None and release['barcode'] != "": albums = spotify.search_albums('upc:%s' % release['barcode']) if len(albums) == 1: colored_out(bcolors.WARNING, ' * Spotify = https://embed.spotify.com/?uri=%s&view=coverart' % (albums[0]['href'],)) image_url = spotify.artwork_url(albums[0]['href']) if image_url is not None: try: img_file = urllib2.urlopen(image_url) im = Image.open(StringIO(img_file.read())) spotify_score = im.size[0] * im.size[1] colored_out(bcolors.NONE, ' * Spotify score:\t%s \t %s' % (spotify_score, image_url)) if spotify_score > best_score: front_uri = image_url best_score = spotify_score except urllib2.HTTPError, e: pass # Evaluate iTunes if itunes is not None and release['barcode'] is not None and release['barcode'] != "": albums = itunes.search({'upc': release['barcode']})