MCPcopy Create free account
hub / github.com/PrathamLearnsToCode/paper2code / download_pdf

Function download_pdf

skills/paper2code/scripts/fetch_paper.py:122–141  ·  view source on GitHub ↗

Download the PDF from arxiv.

(arxiv_id: str, output_path: Path)

Source from the content-addressed store, hash-verified

120
121
122def download_pdf(arxiv_id: str, output_path: Path) -> bool:
123 """Download the PDF from arxiv."""
124 pdf_url = f"https://arxiv.org/pdf/{arxiv_id}.pdf"
125 print(f"Downloading PDF from {pdf_url}...")
126
127 try:
128 resp = requests.get(pdf_url, timeout=60, stream=True)
129 resp.raise_for_status()
130
131 with open(output_path, "wb") as f:
132 for chunk in resp.iter_content(chunk_size=8192):
133 f.write(chunk)
134
135 file_size = output_path.stat().st_size
136 print(f" Downloaded: {file_size / 1024:.0f} KB")
137 return True
138
139 except requests.RequestException as e:
140 print(f" FAILED: {e}", file=sys.stderr)
141 return False
142
143
144def extract_with_pymupdf4llm(pdf_path: Path) -> str | None:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected