feat: save_pdf_from_oa_url 允许202
This commit is contained in:
parent
5dda4efcae
commit
33afe3af0b
|
|
@ -349,7 +349,7 @@ def download_pdf(paper_id):
|
|||
if paper.fetch_status == "downloading":
|
||||
return
|
||||
paper.fetch("downloading")
|
||||
msg = "没有下载渠道"
|
||||
msg = "no_method_to_get_pdf"
|
||||
current_from = ""
|
||||
if paper.oa_url:
|
||||
if "https://doi.org/10.1016" in paper.oa_url:
|
||||
|
|
@ -365,6 +365,8 @@ def download_pdf(paper_id):
|
|||
current_from = "scihub"
|
||||
msg = save_pdf_from_scihub(paper)
|
||||
return msg, current_from
|
||||
if paper.fail_reason is None and paper.has_fulltext_pdf is False:
|
||||
paper.save_fail_reason(msg)
|
||||
finally:
|
||||
paper.fetch_end()
|
||||
|
||||
|
|
@ -377,7 +379,7 @@ def save_pdf_from_oa_url(paper:Paper):
|
|||
paper.save_fail_reason("oa_url_request_error")
|
||||
return f"oa_url_request_error: {str(e)}"
|
||||
|
||||
if res.status_code == 200:
|
||||
if res.status_code in [200, 201, 202]:
|
||||
# 检查是否是PDF文件:检查魔数 %PDF 或 content-type
|
||||
is_pdf = (
|
||||
res.content.startswith(b'%PDF') or
|
||||
|
|
|
|||
Loading…
Reference in New Issue