S-04 jmcomic 配置接入修正
这个提交存在于:
父节点
9b5ab4a956
当前提交
eb0535de6f
共有 1 个文件被更改,包括 13 次插入 和 5 次删除
|
|
@ -40,7 +40,7 @@ class JMDownloadService:
|
||||||
self._write_jmcomic_config(config_path, download_dir)
|
self._write_jmcomic_config(config_path, download_dir)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(
|
title = await asyncio.wait_for(
|
||||||
asyncio.to_thread(self._download_sync, comic_id, config_path),
|
asyncio.to_thread(self._download_sync, comic_id, config_path),
|
||||||
timeout=self.settings.download_timeout_seconds,
|
timeout=self.settings.download_timeout_seconds,
|
||||||
)
|
)
|
||||||
|
|
@ -55,7 +55,7 @@ class JMDownloadService:
|
||||||
|
|
||||||
return DownloadedComic(
|
return DownloadedComic(
|
||||||
comic_id=comic_id,
|
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,
|
work_dir=work_dir,
|
||||||
download_dir=download_dir,
|
download_dir=download_dir,
|
||||||
image_files=image_files,
|
image_files=image_files,
|
||||||
|
|
@ -67,15 +67,23 @@ class JMDownloadService:
|
||||||
if downloaded.work_dir.exists():
|
if downloaded.work_dir.exists():
|
||||||
shutil.rmtree(downloaded.work_dir)
|
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:
|
try:
|
||||||
import jmcomic
|
import jmcomic
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
raise DownloadError("jmcomic is not installed; check plugin requirements.txt") from exc
|
raise DownloadError("jmcomic is not installed; check plugin requirements.txt") from exc
|
||||||
|
|
||||||
logger.info(f"JMDownload: downloading album {comic_id} with {config_path}")
|
logger.info(f"JMDownload: downloading album {comic_id} with {config_path}")
|
||||||
option = jmcomic.JmOption.from_file(filepath=str(config_path))
|
option = jmcomic.create_option_by_file(str(config_path))
|
||||||
jmcomic.download_album(comic_id, option)
|
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:
|
def _write_jmcomic_config(self, config_path: Path, download_dir: Path) -> None:
|
||||||
config = {
|
config = {
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用