调整色花堂PDF格式

This commit is contained in:
liuwei
2025-03-03 15:26:15 +08:00
parent 374d3bec49
commit e8696faeb8

View File

@@ -129,31 +129,31 @@ def fetch_and_create_pdf(url):
magnet_links = re.findall(r'magnet:\?[^ \u4e00-\u9fff]+', post_text) magnet_links = re.findall(r'magnet:\?[^ \u4e00-\u9fff]+', post_text)
# 添加标题和来源URL # 添加标题和来源URL
content.append(Paragraph(f"标题:<br /> {post_title}", title_style)) content.append(Paragraph(f" {post_title}", title_style))
content.append(Spacer(1, 12))
content.append(Paragraph(f"来源URL:<br /> {post_page_url}<br />", normal_style))
content.append(Spacer(1, 12)) content.append(Spacer(1, 12))
# content.append(Paragraph(f"来源URL:<br /> {post_page_url}<br />", normal_style))
# content.append(Spacer(1, 12))
# 解析并格式化 "介绍" 内容 # 解析并格式化 "介绍" 内容
intro_content = [] # intro_content = []
intro_lines = post_text.split("") # 以【分割字段 # intro_lines = post_text.split("【") # 以【分割字段
for line in intro_lines: # for line in intro_lines:
if line.strip(): # if line.strip():
line = "" + line if not line.startswith("") else line # line = "【" + line if not line.startswith("【") else line
if "】:" in line: # if "】:" in line:
key, value = line.split("】:", 1) # key, value = line.split("】:", 1)
intro_content.append(Paragraph(f"{key}】:<br />{value}<br />", normal_style)) # intro_content.append(Paragraph(f"{key}】:<br />{value}<br />", normal_style))
intro_content.append(Spacer(1, 6)) # 字段间距 # intro_content.append(Spacer(1, 6)) # 字段间距
#
# 添加格式化的介绍部分 # # 添加格式化的介绍部分
content.append(Paragraph("介绍:<br />", normal_style)) # content.append(Paragraph("介绍:<br />", normal_style))
content.extend(intro_content) # content.extend(intro_content)
content.append(Spacer(1, 12)) # content.append(Spacer(1, 12))
# 添加磁力链接 # 添加磁力链接
if magnet_links: if magnet_links:
for magnet_link in magnet_links: for magnet_link in magnet_links:
content.append(Paragraph(f"磁力链接:<br /><br /><b>{magnet_link}</b><br /><br />", normal_style)) content.append(Paragraph(f"<br /><br /><b>{magnet_link}</b><br /><br />", normal_style))
content.append(Spacer(1, 12)) content.append(Spacer(1, 12))
# 添加图片 # 添加图片