async def updateSignature(self):
    """ Calculate a cover's "signature" using its thumbnail url. """
    assert(self.thumbnail_sig is None)

    if self.thumbnail_url is None:
      logging.getLogger("Cover").warning("No thumbnail available for %s" % (self))
      return

    # download
    logging.getLogger("Cover").debug("Downloading cover thumbnail '%s'..." % (self.thumbnail_url))
    headers = {}
    self.source.updateHttpHeaders(headers)

    async def pre_cache_callback(img_data):
      return await __class__.crunch(img_data, CoverImageFormat.JPEG, silent=True)

    try:
      store_in_cache_callback, image_data = await self.source.http.query(self.thumbnail_url,
                                                                         cache=__class__.image_cache,
                                                                         headers=headers,
                                                                         pre_cache_callback=pre_cache_callback)
    except Exception as e:
      logging.getLogger("Cover").warning("Download of '%s' failed: %s %s" % (self.thumbnail_url,
                                                                             e.__class__.__qualname__,
                                                                             e))
      return

    # compute sig
    logging.getLogger("Cover").debug("Computing signature of %s..." % (self))
    try:
      self.thumbnail_sig = __class__.computeImgSignature(image_data)
    except Exception as e:
      logging.getLogger("Cover").warning("Failed to compute signature of '%s': %s %s" % (self,
                                                                                         e.__class__.__qualname__,
                                                                                         e))
    else:
      await store_in_cache_callback()
async def updateSignature ( self ) : assert ( self . thumbnail_sig is None ) if self . thumbnail_url is None : logging . getLogger ( "Cover" ) . warning ( "No thumbnail available for %s" % ( self ) ) return logging . getLogger ( "Cover" ) . debug ( "Downloading cover thumbnail '%s'..." % ( self . thumbnail_url ) ) headers = { } self . source . updateHttpHeaders ( headers ) async def pre_cache_callback ( img_data ) : return await __class__ . crunch ( img_data , CoverImageFormat . JPEG , silent = True ) try : store_in_cache_callback , image_data = await self . source . http . query ( self . thumbnail_url , cache = __class__ . image_cache , headers = headers , pre_cache_callback = pre_cache_callback ) except Exception as e : logging . getLogger ( "Cover" ) . warning ( "Download of '%s' failed: %s %s" % ( self . thumbnail_url , e . __class__ . __qualname__ , e ) ) return logging . getLogger ( "Cover" ) . debug ( "Computing signature of %s..." % ( self ) ) try : self . thumbnail_sig = __class__ . computeImgSignature ( image_data ) except Exception as e : logging . getLogger ( "Cover" ) . warning ( "Failed to compute signature of '%s': %s %s" % ( self , e . __class__ . __qualname__ , e ) ) else : await store_in_cache_callback ( )
Calculate a cover's "signature" using its thumbnail url.