Commit ba0b4ec
Changed files (1)
src
preview
src/preview/arxiv.py
@@ -18,6 +18,7 @@ from messages.progress import modify_progress
from messages.sender import send2tg, send_blockquote_texts
from messages.utils import smart_split
from networking import download_file, hx_req
+from preview.utils import add_summary_url
from summarize.summarize import summarize
from utils import nowdt
@@ -68,7 +69,7 @@ async def preview_arxiv(
comment = arxiv_info["comment"]
abstract = arxiv_info["abstract"]
- texts = f"๐**[{title}]({url})**\n๐ฅ{authors}\n๐{updated}\n"
+ texts = f"๐**[{title}]({url})**\n๐{updated}\n๐ฅ{authors}\n"
if comment:
texts += f"๐{comment}"
@@ -79,7 +80,7 @@ async def preview_arxiv(
else:
iframe = f'<iframe src="{pdf_url}" width="100%" height="800px" style="border: none; border-radius: 8px;"></iframe>'
ptag = f'<p style="text-align: center;"><a href="{pdf_url}" target="_blank">ๅจๆฐๆ ็ญพ้กตไธญๆๅผ่ฎบๆ</a></p>'
- sources = [{"type": "text", "text": json.dumps(arxiv_info)}] + await extract_arxiv_tex(arxiv_id) + [{"type": "file", "path": pdf, "mime_type": "application/pdf"}]
+ sources = [{"type": "file", "path": pdf, "mime_type": "application/pdf"}, {"type": "text", "text": json.dumps(arxiv_info)}] + await extract_arxiv_tex(arxiv_id)
summary = await summarize(
sources=sources,
title=title,
@@ -90,7 +91,11 @@ async def preview_arxiv(
description={"emoji": "๐", "name": "ๅๅง่ฎบๆ", "html": iframe + ptag},
force_r2_page=True,
)
- await send_blockquote_texts(client, status_msg, texts=summary.get("texts", ""), **kwargs)
+ telegraph_url = summary.get("telegraph_url")
+ if not telegraph_url:
+ await send_blockquote_texts(client, status_msg, texts=summary.get("texts", ""), **kwargs)
+ else:
+ await add_summary_url(telegraph_url, status_msg)
Path(pdf).unlink(missing_ok=True)