调整文件生成目录,加入一个JAV
This commit is contained in:
@@ -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)
|
||||
|
||||
# 计算内容区域的宽度和高度
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user