# utils.py import asyncio from pathlib import Path from typing import List from aiopath import AsyncPath import logging # 把 1step.py 的主逻辑封装成函数 from step1 import main as step1_main from step2 import main as step2_main log = logging.getLogger("utils") async def run_step1(proxy: str | None = None) -> str: try: await step1_main(proxy) return "画廊链接抓取完成!" except Exception as e: log.exception("step1 执行失败") return f"抓取失败:{e}" async def run_step2(proxy: str | None = None) -> str: try: await step2_main(proxy) return "图片下载完成!" except Exception as e: log.exception("step2 执行失败") return f"下载失败:{e}"