From f6dc5a9ad93b7ec78fa10f112fe62a99b1ab7f1e Mon Sep 17 00:00:00 2001 From: Emmanuel Jemeni Date: Sat, 25 Mar 2023 17:08:40 +0100 Subject: [PATCH] Convert Filepicker.io image URLs to Fiction.live image URLs and warn of potential failure --- ebook/image.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ebook/image.py b/ebook/image.py index 14f8e61..375cfe1 100644 --- a/ebook/image.py +++ b/ebook/image.py @@ -45,8 +45,11 @@ def get_image_from_url(url: str): Basically the same as make_cover_from_url() """ try: - logger.info("Downloading image from " + url) + if url.startswith("https://www.filepicker.io/api/"): + logger.warning("Filepicker.io image detected, converting to Fiction.live image. This might fail.") + url = f"https://cdn3.fiction.live/fp/{url.split('/')[-1]}?&quality=95" img = requests.Session().get(url) + logger.info("Downloading image from " + url) cover = BytesIO(img.content) img_format = Image.open(cover).format