Added ViewURL

This commit is contained in:
2025-08-09 04:24:37 +02:00
parent 14ed66aad7
commit c9928342c2
2 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,14 @@ from os.path import splitext
IMAGE_FORMATS = ["jpeg", "jpg", "png", "gif", "mp4", "webm"]
class ViewURL:
def __init__(self, post_id: int):
self.id = post_id
def __str__(self) -> str:
return f"https://rule34.xxx/index.php?page=post&s=view&id={self.id}"
class ImageURL:
def __init__(self, image_dir: int, image_id: str, image_format: str):
self.dir: int = image_dir

View File

@ -1,5 +1,5 @@
from .post import Post
from .url import ImageURL, SampleURL, ThumbnailURL, parse_image_url
from .url import ViewURL, ImageURL, SampleURL, ThumbnailURL, parse_image_url
from .scraper import scraper
from .dockid import is_view
from io import BytesIO
@ -50,7 +50,7 @@ class View:
self._thumb_data: bytes | None = None
self._thumb: ImageFile | None = None
self.thumb_url: ThumbnailURL | None = None
document = scraper.get_html(f"https://rule34.xxx/index.php?page=post&s=view&id={id}")
document = scraper.get_html(ViewURL(self.id))
if not is_view(document):
raise ViewMissingException("View does not exist")