Compare commits

...

4 Commits

Author SHA1 Message Date
66bef9279f Merge branch 'scraper' into scraper-dev 2025-10-09 20:07:14 +02:00
f55f118271 Merge branch 'master' into scraper 2025-10-09 20:07:02 +02:00
3279e8e3c0 Scan video formats aswell 2025-10-09 20:06:51 +02:00
1dc17d7670 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.
2025-10-09 20:05:36 +02:00
2 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from .scraper import scraper 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 io import BytesIO
from PIL import Image from PIL import Image
from PIL.ImageFile import ImageFile from PIL.ImageFile import ImageFile
@ -57,7 +57,7 @@ class Post:
def get_image_data(self) -> bytes: def get_image_data(self) -> bytes:
if self._image_data is not None: if self._image_data is not None:
return self._image_data return self._image_data
for ext in IMAGE_FORMATS: for ext in VIDEO_FORMATS + IMAGE_FORMATS:
try: try:
self._image_data = scraper.get(ImageURL(self.image_dir, self.image_id, ext), retry=False) self._image_data = scraper.get(ImageURL(self.image_dir, self.image_id, ext), retry=False)
self._image_format = ext self._image_format = ext

View File

@ -123,8 +123,7 @@ def get_image(post_id: int = None):
if path.exists(): if path.exists():
return send_file(path) return send_file(path)
else: else:
post = py34.Post(entry.post, entry.dir, entry.image, entry.tags, entry.thumbnail) image = py34.scraper.scraper.get(py34.url.ImageURL(entry.dir, entry.image, enttype2ext(entry.type)))
image = post.get_image_data()
with open(path, "wb") as file: with open(path, "wb") as file:
file.write(image) file.write(image)
return send_file(path) return send_file(path)