SanYeCao-Nonebot/src/clover_jm/jm_comic.py
SlyAimer feb53b1a31 feat(jm): 添加JM漫画下载功能及相关模块
新增jm_download插件、jm_comic核心下载逻辑、disguise_pdf文件处理工具
扩展delete_file功能,添加批量删除和文件夹删除方法
更新路径配置和菜单选项
2025-03-31 17:59:30 +08:00

28 lines
962 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import jmcomic
from src.clover_jm.disguise_pdf import *
from src.configs.path_config import jm_path
from src.clover_image.delete_file import delete_file_batch,delete_folder
async def download_jm(album_id: str| None):
album_detail,downloader = jmcomic.download_album(album_id)
original_path = os.getcwd()+f"/{album_detail.title}"
# 将图片转换为PDF
await webp_to_pdf(original_path,jm_path +f"{album_id}.pdf")
pdf_file = jm_path + f"{album_id}.pdf"
jpg_file = jm_path + 'temp.jpg'
zip_file = jm_path + "resume.zip"
output_file = jm_path +"merged.jpg"
if os.path.exists(pdf_file) and os.path.exists(jpg_file):
await zip_pdf(pdf_file, zip_file)
await merge_files(jpg_file, zip_file, output_file)
await delete_file_batch([zip_file, pdf_file])
await delete_folder(original_path)
else:
print("PDF文件或JPG文件不存在请检查文件路径。")
return output_file