def pack_image(mime, description, imagedata, type_): assert APICType.is_valid(type_) size = len(imagedata) data = struct.pack("<bi", type_, size) data += mime.encode("utf-16-le") + "\x00\x00" data += description.encode("utf-16-le") + "\x00\x00" data += imagedata return data
def get_primary_image(self): """Returns the primary embedded image""" try: tag = FLAC(self["~filename"]) except EnvironmentError: return None covers = tag.pictures if not covers: return super(FLACFile, self).get_primary_image() covers.sort(key=lambda c: APICType.sort_key(c.type)) cover = covers[0] fileobj = get_temp_cover_file(cover.data) return EmbeddedImage(fileobj, cover.mime, cover.width, cover.height, cover.depth, cover.type)
def get_primary_image(self): """Returns the primary embedded image""" try: tag = FLAC(self["~filename"]) except EnvironmentError: return None covers = tag.pictures if not covers: return super(FLACFile, self).get_primary_image() covers.sort(key=lambda c: APICType.sort_key(c.type)) cover = covers[0] fileobj = get_temp_cover_file(cover.data) return EmbeddedImage( fileobj, cover.mime, cover.width, cover.height, cover.depth, cover.type)