From c9928342c2ad150d329c8e9adff8e08fdcee0e25 Mon Sep 17 00:00:00 2001 From: Tomuxs Date: Sat, 9 Aug 2025 04:24:37 +0200 Subject: [PATCH] Added ViewURL --- py34/url.py | 8 ++++++++ py34/view.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/py34/url.py b/py34/url.py index 62da613..e784d9b 100644 --- a/py34/url.py +++ b/py34/url.py @@ -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 diff --git a/py34/view.py b/py34/view.py index 7b19f89..313d74f 100644 --- a/py34/view.py +++ b/py34/view.py @@ -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")