从今日推送文件加载论文列表
()
| 37 | |
| 38 | |
| 39 | def load_today_push() -> list: |
| 40 | """从今日推送文件加载论文列表""" |
| 41 | import glob |
| 42 | |
| 43 | # 查找今天的推送文件 |
| 44 | today = datetime.now().strftime("%Y-%m-%d") |
| 45 | push_files = glob.glob("test_push*.txt") |
| 46 | |
| 47 | if not push_files: |
| 48 | print("未找到推送文件,请先运行 daily-push") |
| 49 | return [] |
| 50 | |
| 51 | # 读取最新的推送文件 |
| 52 | latest_file = max(push_files, key=os.path.getmtime) |
| 53 | print(f"读取推送文件:{latest_file}") |
| 54 | |
| 55 | papers = [] |
| 56 | with open(latest_file, 'r', encoding='utf-8') as f: |
| 57 | for line in f: |
| 58 | # 匹配格式:01. 2604.07258v1: 标题 |
| 59 | import re |
| 60 | match = re.match(r'^\s*(\d+)\.\s*([\w\.]+):\s*(.+)$', line) |
| 61 | if match: |
| 62 | num = int(match.group(1)) |
| 63 | arxiv_id = match.group(2) |
| 64 | title = match.group(3) |
| 65 | papers.append({ |
| 66 | "id": num, |
| 67 | "arxiv_id": arxiv_id, |
| 68 | "title": title |
| 69 | }) |
| 70 | |
| 71 | return papers |
| 72 | |
| 73 | |
| 74 | def main(): |