nber-cli 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nber_cli-0.1.1 → nber_cli-0.1.2}/PKG-INFO +1 -1
- {nber_cli-0.1.1 → nber_cli-0.1.2}/pyproject.toml +1 -1
- {nber_cli-0.1.1 → nber_cli-0.1.2}/src/nber_cli/downloader.py +9 -5
- {nber_cli-0.1.1 → nber_cli-0.1.2}/uv.lock +1 -1
- {nber_cli-0.1.1 → nber_cli-0.1.2}/.github/workflows/publish.yml +0 -0
- {nber_cli-0.1.1 → nber_cli-0.1.2}/.gitignore +0 -0
- {nber_cli-0.1.1 → nber_cli-0.1.2}/.python-version +0 -0
- {nber_cli-0.1.1 → nber_cli-0.1.2}/LICENSE +0 -0
- {nber_cli-0.1.1 → nber_cli-0.1.2}/README.md +0 -0
- {nber_cli-0.1.1 → nber_cli-0.1.2}/src/nber_cli/__init__.py +0 -0
|
@@ -125,16 +125,20 @@ async def update_paper_state(paper_id: str, status: str):
|
|
|
125
125
|
|
|
126
126
|
async def download_paper(paper_id: str, save_path: str):
|
|
127
127
|
"""下载单个NBER论文"""
|
|
128
|
-
if await get_paper_state(paper_id) == 'ok':
|
|
129
|
-
logger.info(f"Skipping {paper_id}, already downloaded.")
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
url = f"https://www.nber.org/papers/{paper_id}.pdf"
|
|
133
128
|
filepath = os.path.join(save_path, f"{paper_id}.pdf")
|
|
134
129
|
|
|
135
130
|
# 确保保存路径存在
|
|
136
131
|
os.makedirs(save_path, exist_ok=True)
|
|
137
132
|
|
|
133
|
+
state = await get_paper_state(paper_id)
|
|
134
|
+
if state == 'ok' and os.path.exists(filepath):
|
|
135
|
+
logger.info(f"Skipping {paper_id}, already downloaded.")
|
|
136
|
+
return
|
|
137
|
+
if state == 'ok' and not os.path.exists(filepath):
|
|
138
|
+
logger.info(f"{paper_id} marked as downloaded but file missing, re-downloading.")
|
|
139
|
+
|
|
140
|
+
url = f"https://www.nber.org/papers/{paper_id}.pdf"
|
|
141
|
+
|
|
138
142
|
ua = UserAgent()
|
|
139
143
|
headers = {'User-Agent': ua.random}
|
|
140
144
|
retry_options = ExponentialRetry(attempts=MAX_RETRIES)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|