Move list of known extensions to py34.url
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from .scraper import scraper
|
||||
from .url import ImageURL, ThumbnailURL
|
||||
from .url import ImageURL, ThumbnailURL, IMAGE_FORMATS
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
from PIL.ImageFile import ImageFile
|
||||
@ -44,7 +44,7 @@ class Post:
|
||||
def get_image_data(self) -> bytes:
|
||||
if self._image_data is not None:
|
||||
return self._image_data
|
||||
for ext in ["jpeg", "png", "gif", "mp4", "webm", "jpg"]:
|
||||
for ext in IMAGE_FORMATS:
|
||||
try:
|
||||
self._image_data = scraper.get(ImageURL(self.image_dir, self.image_id, ext), retry=False)
|
||||
self._image_format = ext
|
||||
|
||||
@ -2,6 +2,9 @@ from urllib.parse import urlparse
|
||||
from os.path import splitext
|
||||
|
||||
|
||||
IMAGE_FORMATS = ["jpeg", "png", "gif", "mp4", "webm", "jpg"]
|
||||
|
||||
|
||||
class ImageURL:
|
||||
def __init__(self, image_dir: int, image_id: str, image_format: str):
|
||||
self.dir: int = image_dir
|
||||
|
||||
Reference in New Issue
Block a user