Skip to content

Commit 1e721db

Browse files
committed
MOD: Cleanup handling of URLs
1 parent c65421d commit 1e721db

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

databento/historical/api/batch.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,20 @@ def download(
271271
)
272272

273273
urls = details.get("urls")
274-
if urls:
275-
url = urls.get("https")
276-
if not url:
277-
raise ValueError(
278-
f"Cannot download {filename} over HTTPS "
279-
"('download' delivery is not available for this job).",
280-
)
281-
else:
282-
# Handle legacy manifest.json without the 'urls' field
283-
base_url = "https://api.databento.com/v0/batch/download"
284-
url = f"{base_url}/{job_id}/{filename}"
274+
if not urls:
275+
raise ValueError(
276+
f"Cannot download {filename}, URLs were not found in manifest.",
277+
)
278+
279+
https_url = urls.get("https")
280+
if not https_url:
281+
raise ValueError(
282+
f"Cannot download {filename} over HTTPS, "
283+
"'download' delivery is not available for this job.",
284+
)
285285

286286
self._download_file(
287-
url=url,
287+
url=https_url,
288288
filesize=int(details["size"]),
289289
output_path=output_path,
290290
)

0 commit comments

Comments
 (0)