diff --git a/RomM/api.py b/RomM/api.py index d4a790d..0a10673 100644 --- a/RomM/api.py +++ b/RomM/api.py @@ -652,6 +652,7 @@ def download_rom(self) -> None: ) if not catalogue_path: continue + os.makedirs(catalogue_path, exist_ok=True) filename = self._sanitize_filename(rom.fs_name_no_ext) if rom.summary: diff --git a/RomM/imageutils.py b/RomM/imageutils.py index cc09853..c39c062 100644 --- a/RomM/imageutils.py +++ b/RomM/imageutils.py @@ -2,6 +2,7 @@ from io import BytesIO from typing import Optional from urllib.error import HTTPError, URLError +from urllib.parse import urljoin from urllib.request import Request, urlopen from PIL import Image, ImageDraw @@ -54,6 +55,10 @@ def add_rounded_corners(self, image: Image.Image, radius: int = 20): def load_image_from_url(self, url: str, headers: dict) -> Image.Image | None: try: + # Use urljoin to properly resolve relative URLs against the host + if url: + url = urljoin(f"{self.host}/", url) + req = Request(url.split("?")[0], headers=headers) with urlopen(req, timeout=60) as response: # trunk-ignore(bandit/B310) data = response.read()