Skip to content

kau10082/Pubmed_Bot

Repository files navigation

PubMed_Bot

自架的 PubMed 文獻訂閱 / 追蹤機器人 — 每日自動監測新文獻、AI 中文摘要,同時送進信箱、Zotero 與 Obsidian,是 PubMed Email Alert/RSS 的免費替代方案。 A self-hosted PubMed literature-alert / monitoring bot — daily automated monitoring with AI summaries in Chinese, delivered to your inbox, Zotero, and Obsidian at once. A free alternative to PubMed email alerts / RSS.


1. 專案簡介 | About The Project

這是一個「自動幫你追論文」的小幫手。它每天早上自動去 PubMed(全球最大的醫學文獻資料庫)幫你找出你關心領域的高品質新論文,用 AI 寫成好懂的中文摘要,然後寄到你的信箱,還能存進 Zotero,並把每篇寫成 Obsidian 筆記(透過 Google Drive 中轉,詳見第 4 節說明)。

This is a little assistant that "tracks papers for you." Every morning it automatically searches PubMed (the world's biggest medical-literature database) for new, high-quality papers in the fields you care about, writes an easy-to-read summary with AI, emails it to you, files it into Zotero, and turns each paper into an Obsidian note (relayed through Google Drive — see Section 4 for how).


2. 為什麼要用這個專案? | Why Choose This?

GitHub 上「每天抓新論文寄給你」的工具其實不少,但它們大多只做到「提醒」。這個專案的定位不太一樣:它不只是一個提醒器,而是一個接進你個人知識庫的文獻中樞。核心優勢如下:

There are quite a few "fetch new papers daily and notify you" tools out there — but most of them stop at "alerting." This project is positioned differently: it's not just another alert bot, it's a literature hub that feeds directly into your personal knowledge base. Here's what sets it apart:

  • 一次送到三個地方,各自可開關(Email+Zotero+Obsidian):多數同類工具只推送到單一去向(信箱、通訊軟體、或書目軟體擇一);這裡一趟流程同時扇出三路——摘要寄進信箱、書目存進 Zotero、筆記寫進 Google Drive(再由你自己的 WebDAV 同步接進 Obsidian;本專案不直接連 Obsidian),讓新文獻直接變成你知識庫的一部分,而不是又一封待處理的信。 Three destinations at once, each independently switchable (Email + Zotero + Obsidian): most similar tools push to a single place (inbox, messenger, or reference manager — pick one). Here, one run fans out to all three — the summary lands in your inbox, the reference in Zotero, and a note is written to Google Drive (which reaches Obsidian through your own WebDAV sync; the bot does not connect to Obsidian directly), so new papers become part of your knowledge base directly instead of yet another email to deal with.

  • 只給你「好」論文,而且每個主題可以有自己的標準:內建期刊品質門檻(依 SCImago SJR 期刊分級過濾),先幫你擋掉大量低品質內容。更進一步:每條主題線可以各自設定門檻——例如主流領域只收 Q1 頂級期刊、冷門領域放寬到 Q2 以免漏掉——而不是全部共用一條粗糙的全域標準。 Only good papers — and each topic gets its own bar: a built-in journal-quality gate (filtered by SCImago SJR journal rankings) blocks the flood of low-quality content up front. Better yet, each topic line can set its own threshold — e.g., top-tier Q1 journals only for a mainstream field, but relaxed to Q2 for a niche topic so nothing slips through — instead of one crude global filter for everything.

  • 讀不完?讓 AI 幫你先讀:每篇論文都有 AI 產生的中文摘要,信件開頭還有「一句話總結」清單,通勤時滑一下就能掌握當天重點——不是直接把英文原文摘要丟給你。 Too much to read? Let AI read it first: every paper gets an AI-generated summary in Chinese, and the email opens with a one-line-takeaway list — skim it on your commute. You're not just handed the raw English abstract.

  • 改設定不用改程式:搜尋主題、關鍵字、品質門檻、輸出開關,全部集中在一個 config/settings.yaml 設定檔。它不是為某個疾病寫死的腳本,而是一套任何人都能換上自己主題的通用框架Reconfigure without touching code: topics, keywords, quality thresholds, and output switches all live in one config/settings.yaml file. It's not a script hard-coded for one disease — it's a general framework anyone can point at their own topics.

  • 完全免費、自己作主:跑在免費的 GitHub Actions 上,資料留在你自己手上,不必付費訂閱任何服務。 Free and fully in your control: runs on free GitHub Actions, your data stays yours, and there's no paid subscription anywhere.


3. 最新更新 | What's New

最近一批更新(2026-06):

Latest updates (2026-06):

  • 摘要不再被截斷:修正一個會讓 AI 只讀到半篇摘要的隱形 bug,「一句話總結」現在更精準、更白話。 No more truncated abstracts: fixed a hidden bug that fed AI only half the abstract; the one-line takeaways are now sharper and plainer.
  • Google Drive 授權長效化:修好了「筆記每 7 天就同步失敗」的問題(原因是 OAuth app 停在測試模式),並在授權失效時於信件最上方跳出提醒。 Long-lived Google Drive auth: fixed the "notes stop syncing every 7 days" bug (the OAuth app was stuck in testing mode), and the email now shows an alert at the top if the token dies.
  • 新增「戒菸」主題線,並讓每條主題線可各自設定期刊品質門檻。 Added a "smoking cessation" topic line, and each topic line can now set its own journal-quality bar.
  • 三個輸出(Email/Zotero/Obsidian)可各自開關;主題範圍調校(肺部/重症線收斂得更準)。 The three outputs (Email / Zotero / Obsidian) can each be switched on/off; topic scopes were tuned (the pulmonary and critical-care lines are more precise now).

4. 快速開始 | Getting Started

前置需求:Python 3.10 以上,以及幾組 API 金鑰(PubMed、Gemini,以及選用的 Zotero/Gmail/Google Drive)。

Prerequisites: Python 3.10+, and a few API keys (PubMed, Gemini, plus optional Zotero / Gmail / Google Drive).

步驟一:下載專案、安裝套件

Step 1: Clone and install

git clone https://github.com/kau10082/Pubmed_Bot.git
cd Pubmed_Bot
pip install -r requirements.txt

步驟二:下載期刊品質資料(一年一次)。到 SCImago 點「Download data」,存成 data/scimago.csv,再壓縮:

Step 2: Get the journal-quality data (once a year). On SCImago click "Download data", save as data/scimago.csv, then compress:

gzip -9 data/scimago.csv

步驟三:填入金鑰。把 .env.template 複製成 .env 填入(本機測試用);正式排程則把同樣的值放進 GitHub → Settings → Secrets。

Step 3: Add your keys. Copy .env.template to .env and fill it in (for local testing); for the scheduled run, put the same values into GitHub → Settings → Secrets.

步驟四(選用,Obsidian 同步才需要):取得 Google Drive 授權

Step 4 (optional, only for Obsidian sync): authorize Google Drive.

pip install google-auth-oauthlib
python get_refresh_token.py

注意:記得把 Google OAuth app 設為 Production(正式版),否則授權每 7 天會失效。 Note: set your Google OAuth app to Production, otherwise the authorization expires every 7 days.

Obsidian 是怎麼接上的?(重要) 本專案不直接連 Obsidian,它只把每篇筆記(.md)寫進一個 Google Drive 資料夾。要讓筆記出現在 Obsidian,是你自己把那個 Drive 資料夾透過 WebDAV 接進 Obsidian vault(例如把 Google Drive 掛成 WebDAV,或用同步工具)。整條路是:

How does Obsidian actually get connected? (important) This project does not talk to Obsidian directly — it only writes each note (.md) into one Google Drive folder. The notes show up in Obsidian because you link that Drive folder into your Obsidian vault over WebDAV (e.g. mounting Google Drive as WebDAV, or using a sync tool). The full path is:

Bot(Branch C)→ 寫入 Google Drive 資料夾 → 你的 WebDAV 同步 → Obsidian vault
Bot (Branch C) → writes to a Google Drive folder → your WebDAV sync → Obsidian vault

5. 基本使用方式 | Usage

自動執行:設好 GitHub Secrets 後就完全不用管,每天台灣時間 04:30 自動寄信給你。

Automatic: once your GitHub Secrets are set, it just runs every day at 04:30 (Taiwan time) and emails you.

手動執行一次:到 GitHub 的 Actions 分頁 → 選 Run workflow,還能用下拉選單臨時開關 Zotero/Email/Google Drive。

Run once manually: go to the Actions tab → Run workflow; dropdowns let you toggle Zotero / Email / Google Drive just for that run.

在自己電腦跑

Run on your own computer:

python pubmed_automation.py
# 臨時關掉某個輸出 / turn one output off for this run:
RUN_ZOTERO=off python pubmed_automation.py

想改搜尋主題、關鍵字、品質門檻?全部都在 config/settings.yaml,改完存檔即可,不用碰程式碼

Want to change topics, keywords, or the quality bar? It's all in config/settings.yaml — just edit and save, no coding required.


6. 目錄結構 | Repository Structure

Pubmed_Bot/
├── pubmed_automation.py    # 主程式(搜尋→篩選→摘要→寄送)| main pipeline
├── sjr.py                  # 查期刊品質分級 | journal-quality (SJR) lookup
├── get_refresh_token.py    # 一次性取得 Google Drive 授權 | one-time Drive auth helper
├── config/
│   └── settings.yaml       # 所有設定(主題/關鍵字/門檻…)| all settings
├── data/
│   └── scimago.csv.gz      # 期刊品質資料表 | journal-quality dataset
├── .github/workflows/
│   └── main.yml            # 每日自動排程 | daily schedule
├── .env.template           # 金鑰填寫範本 | secrets template
├── requirements.txt        # 需要的套件清單 | dependencies
└── LICENSE                 # 授權條款 | license

一句話帶過各部分:pubmed_automation.py 是大腦(負責整個流程)、sjr.py 是品質守門員、config/settings.yaml 是你的「遙控器」(改這裡就能調整行為)、data/ 放期刊評分資料、.github/ 負責每天定時開跑。

In a nutshell: pubmed_automation.py is the brain (runs the whole flow), sjr.py is the quality gatekeeper, config/settings.yaml is your "remote control" (change behavior here), data/ holds the journal-ranking data, and .github/ handles the daily schedule.


7. 貢獻指南 | Contributing

非常歡迎你一起讓它更好!不管是修 bug、加功能,還是只是回報問題,都很感謝。

Contributions are very welcome — bug fixes, new features, or just reporting an issue, all appreciated!

  • 發現問題?Issues 開一則,描述你遇到的狀況就好。 Found a problem? Open an Issue and describe what happened.
  • 想改程式?Fork 這個專案 → 開一個新分支 → 改完後發一個 Pull Request,我們會一起看。 Want to change the code? Fork the repo → create a branch → open a Pull Request when you're done, and we'll review it together.

8. 授權條款 | License

本專案程式碼採用 MIT 授權:你可以自由使用、修改、散布,商用也可以,只要保留原本的授權與版權標示即可。

The code is under the MIT License: you're free to use, modify, and distribute it (commercial use included), as long as you keep the original license and copyright notice.

注意:附帶的期刊資料 data/scimago.csv.gz 來自 SCImago(源自 Elsevier Scopus),僅供非商業學術/個人用途,不在 MIT 授權範圍內;若要再利用請標示 SCImago 出處並確認其條款。

Note: the bundled journal data data/scimago.csv.gz comes from SCImago (derived from Elsevier Scopus), is for non-commercial academic/personal use only, and is not covered by the MIT License; if you reuse it, credit SCImago and review their terms.

About

Daily PubMed literature-alert & monitoring bot: AI paper summaries delivered to your inbox, Zotero & Obsidian. A free, self-hosted alternative to PubMed email alerts / RSS. | 每天自動追蹤 PubMed 新論文、用 AI 產生中文摘要,一次送進 Email、Zotero 與 Obsidian——PubMed Email Alert/RSS 的免費自架替代方案。

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages