From 73291d096d066addf974e43c96158a231805c9e3 Mon Sep 17 00:00:00 2001 From: Lukas Schwab Date: Tue, 19 Aug 2025 17:13:38 -0700 Subject: [PATCH] Deprecate download helpers --- arxiv/__init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/arxiv/__init__.py b/arxiv/__init__.py index 8508f4e..62a4a4e 100644 --- a/arxiv/__init__.py +++ b/arxiv/__init__.py @@ -211,6 +211,9 @@ def download_pdf( Downloads the PDF for this result to the specified directory. The filename is generated by calling `to_filename(self)`. + + **Deprecated:** future versions of this client library will not provide + download helpers (out of scope). Use `result.pdf_url` directly. """ if not filename: filename = self._get_default_filename() @@ -230,16 +233,23 @@ def download_source( directory. The filename is generated by calling `to_filename(self)`. + + **Deprecated:** future versions of this client library will not provide + download helpers (out of scope). Use `result.source_url` directly. """ if not filename: filename = self._get_default_filename("tar.gz") path = os.path.join(dirpath, filename) - pdf_url = Result._substitute_domain(self.pdf_url, download_domain) - # Bodge: construct the source URL from the PDF URL. - src_url = pdf_url.replace("/pdf/", "/src/") - written_path, _ = urlretrieve(src_url, path) + source_url = Result._substitute_domain(self.source_url(), download_domain) + written_path, _ = urlretrieve(source_url, path) return written_path + def source_url(self) -> str: + """ + Derives a URL for the source tarfile for this result. + """ + return self.pdf_url.replace("/pdf/", "/src/") + def _get_pdf_url(links: List[Link]) -> str: """ Finds the PDF link among a result's links and returns its URL.