Small fixes
This commit is contained in:
parent
d56b5dedff
commit
d93beb9201
7 changed files with 95 additions and 42 deletions
|
|
@ -7,22 +7,23 @@ import subprocess
|
|||
import sys
|
||||
import tarfile
|
||||
import urllib.request
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
PROTOMAPS_BASE = "https://build.protomaps.com"
|
||||
UK_BBOX = "-10.5,49,5,61"
|
||||
MAX_AGE_DAYS = 14
|
||||
USER_AGENT = "property-map-tiles/1.0"
|
||||
|
||||
|
||||
def find_latest_build() -> str:
|
||||
"""Find the most recent available Protomaps daily build."""
|
||||
today = datetime.utcnow().date()
|
||||
today = datetime.now(UTC).date()
|
||||
for i in range(MAX_AGE_DAYS):
|
||||
d = today - timedelta(days=i)
|
||||
url = f"{PROTOMAPS_BASE}/{d:%Y%m%d}.pmtiles"
|
||||
req = urllib.request.Request(url, method="HEAD")
|
||||
req = urllib.request.Request(url, method="HEAD", headers={"User-Agent": USER_AGENT})
|
||||
try:
|
||||
urllib.request.urlopen(req)
|
||||
print(f"Found build: {d:%Y%m%d}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue