mirror of
https://github.com/kemayo/leech
synced 2025-12-24 17:23:55 +01:00
Fix whitespace
This commit is contained in:
parent
b25c497e46
commit
cc29936d92
1 changed files with 5 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import logging
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def make_cover(title, author, width=600, height=800, fontname="Helvetica", fontsize=40, bgcolor=(120, 20, 20), textcolor=(255, 255, 255), wrapat=30):
|
||||
img = Image.new("RGBA", (width, height), bgcolor)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
|
@ -30,6 +31,7 @@ def make_cover(title, author, width=600, height=800, fontname="Helvetica", fonts
|
|||
output.seek(0)
|
||||
return output
|
||||
|
||||
|
||||
def make_cover_from_url(url, title, author):
|
||||
try:
|
||||
logger.info("Downloading cover from " + url)
|
||||
|
|
@ -38,12 +40,13 @@ def make_cover_from_url(url, title, author):
|
|||
|
||||
if Image.open(cover).format != "PNG":
|
||||
cover = _convert_to_png(cover)
|
||||
except Exception as e:
|
||||
except Exception as e:
|
||||
logger.info("Encountered an error downloading cover: " + e)
|
||||
cover = make_cover(title, author)
|
||||
|
||||
return cover
|
||||
|
||||
|
||||
def _convert_to_png(image_bytestream):
|
||||
png_image = BytesIO()
|
||||
Image.open(image_bytestream).save(png_image, format="PNG")
|
||||
|
|
@ -52,6 +55,7 @@ def _convert_to_png(image_bytestream):
|
|||
|
||||
return png_image
|
||||
|
||||
|
||||
def _safe_font(preferred, *args, **kwargs):
|
||||
for font in (preferred, "Helvetica", "FreeSans", "Arial"):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue