调整文件生成目录,加入一个JAV

This commit is contained in:
liuwei
2026-01-14 15:43:05 +08:00
parent 20624f39e1
commit 9b2952d8df
2 changed files with 13 additions and 8 deletions

View File

@@ -133,11 +133,14 @@ def fetch_and_create_pdf(url):
today_posts.append(post)
today_posts = today_posts[::-1] # 倒序处理
# 设置PDF
# 修改PDF文件路径到项目根目录的temp目录下
pdf_filename = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
'temp',
f"JAV-{today}-{len(today_posts)}.pdf")
# 设置PDF - 保存到 temp/JAV 目录
base_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
pdf_filename = os.path.join(base_dir, 'temp', 'JAV', f"JAV-{today}-{len(today_posts)}.pdf")
# 确保目录存在
pdf_dir = os.path.dirname(pdf_filename)
if not os.path.exists(pdf_dir):
os.makedirs(pdf_dir)
doc = SimpleDocTemplate(pdf_filename, pagesize=A3)
# 计算内容区域的宽度和高度

View File

@@ -117,9 +117,11 @@ def fetch_and_create_pdf(url):
normal_style = styles['Normal']
normal_style.fontName = 'SimHei'
# 路径逻辑
save_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'temp')
if not os.path.exists(save_path): os.makedirs(save_path)
# 路径逻辑 - 保存到 temp/JAV 目录
base_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
save_path = os.path.join(base_dir, 'temp', 'JAV')
if not os.path.exists(save_path):
os.makedirs(save_path)
pdf_filename = os.path.join(save_path, f"JAV-{datetime.now().strftime('%Y-%m-%d')}-{len(today_posts)}.pdf")
doc = SimpleDocTemplate(pdf_filename, pagesize=A3)