From 1dc17d7670ebceae4f5b9bbc02045636182e70da Mon Sep 17 00:00:00 2001 From: Tomas Date: Thu, 9 Oct 2025 20:05:36 +0200 Subject: [PATCH 1/2] Don't create py34.Post for downloading images py34.Post does extension scan, that is not required as it is saved inside the block data. --- scraper/server/__main__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scraper/server/__main__.py b/scraper/server/__main__.py index 25ae609..40f009e 100644 --- a/scraper/server/__main__.py +++ b/scraper/server/__main__.py @@ -123,8 +123,7 @@ def get_image(post_id: int = None): if path.exists(): return send_file(path) else: - post = py34.Post(entry.post, entry.dir, entry.image, entry.tags, entry.thumbnail) - image = post.get_image_data() + image = py34.scraper.scraper.get(py34.url.ImageURL(entry.dir, entry.image, enttype2ext(entry.type))) with open(path, "wb") as file: file.write(image) return send_file(path) From 3279e8e3c08904974eef7375540c57a903d76970 Mon Sep 17 00:00:00 2001 From: Tomas Date: Thu, 9 Oct 2025 20:06:51 +0200 Subject: [PATCH 2/2] Scan video formats aswell --- py34/post.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py34/post.py b/py34/post.py index d0e4b6e..3a725c5 100644 --- a/py34/post.py +++ b/py34/post.py @@ -1,5 +1,5 @@ from .scraper import scraper -from .url import ImageURL, ThumbnailURL, IMAGE_FORMATS +from .url import ImageURL, ThumbnailURL, IMAGE_FORMATS, VIDEO_FORMATS from io import BytesIO from PIL import Image from PIL.ImageFile import ImageFile @@ -57,7 +57,7 @@ class Post: def get_image_data(self) -> bytes: if self._image_data is not None: return self._image_data - for ext in IMAGE_FORMATS: + for ext in VIDEO_FORMATS + IMAGE_FORMATS: try: self._image_data = scraper.get(ImageURL(self.image_dir, self.image_id, ext), retry=False) self._image_format = ext