Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mtg_proxies/scryfall/scryfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ def get_file(file_name: str, url: str, *, silent: bool = False) -> str:
return str(file_path)


def get_headers() -> dict:
return {"User-Agent": f"mtg-proxies/{version('mtg-proxies')}", "Accept": "*/*"}

def download(url: str, dst: Path | str, *, chunk_size: int = 1024 * 4, silent: bool = False) -> None:
"""Download a file with a tqdm progress bar."""
with requests.get(
url, stream=True, headers={"User-Agent": f"mtg-proxies/{version('mtg-proxies')}", "Accept": "*/*"}
) as req:
with requests.get(url, stream=True, headers=get_headers()) as req:
req.raise_for_status()
file_size = int(req.headers["Content-Length"]) if "Content-Length" in req.headers else None
with (
Expand Down Expand Up @@ -93,7 +94,7 @@ def depaginate(url: str) -> list[dict]:
list: Concatenation of all `data` entries.
"""
with scryfall_rate_limiter:
response = requests.get(url).json()
response = requests.get(url, headers=get_headers()).json()
assert response["object"]

if "data" not in response:
Expand Down