From eb0535de6f782fc681f7462370ffcfe2a891263c Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 7 Jul 2026 00:09:32 +0800 Subject: [PATCH] =?UTF-8?q?S-04=20jmcomic=20=E9=85=8D=E7=BD=AE=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/download.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/services/download.py b/services/download.py index 8729976..3d31bad 100644 --- a/services/download.py +++ b/services/download.py @@ -40,7 +40,7 @@ class JMDownloadService: self._write_jmcomic_config(config_path, download_dir) try: - await asyncio.wait_for( + title = await asyncio.wait_for( asyncio.to_thread(self._download_sync, comic_id, config_path), timeout=self.settings.download_timeout_seconds, ) @@ -55,7 +55,7 @@ class JMDownloadService: return DownloadedComic( comic_id=comic_id, - title=infer_album_title(download_dir, comic_id), + title=title or infer_album_title(download_dir, comic_id), work_dir=work_dir, download_dir=download_dir, image_files=image_files, @@ -67,15 +67,23 @@ class JMDownloadService: if downloaded.work_dir.exists(): shutil.rmtree(downloaded.work_dir) - def _download_sync(self, comic_id: str, config_path: Path) -> None: + def _download_sync(self, comic_id: str, config_path: Path) -> str: try: import jmcomic except ImportError as exc: raise DownloadError("jmcomic is not installed; check plugin requirements.txt") from exc logger.info(f"JMDownload: downloading album {comic_id} with {config_path}") - option = jmcomic.JmOption.from_file(filepath=str(config_path)) - jmcomic.download_album(comic_id, option) + option = jmcomic.create_option_by_file(str(config_path)) + result = jmcomic.download_album(comic_id, option=option, check_exception=True) + return self._extract_album_title(result) + + def _extract_album_title(self, result: object) -> str: + album = getattr(result, "album", None) + if album is None and isinstance(result, tuple) and result: + album = result[0] + title = getattr(album, "title", "") if album is not None else "" + return str(title).strip() def _write_jmcomic_config(self, config_path: Path, download_dir: Path) -> None: config = {