43 lines
1.1 KiB
Bash
43 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Download DOP20 assets (JP2/J2W/XML) listed line-by-line in archive/dop20/filelist.txt.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
|
|
DOP_ROOT="$ROOT/raw/dop20"
|
|
LIST="${LIST:-$ROOT/archive/dop20/filelist.txt}"
|
|
OUT_JP2="$DOP_ROOT/jp2"
|
|
OUT_J2W="$DOP_ROOT/j2w"
|
|
OUT_META="$DOP_ROOT/meta"
|
|
|
|
if [[ ! -f "$LIST" ]]; then
|
|
echo "Missing filelist: $LIST" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$OUT_JP2" "$OUT_J2W" "$OUT_META"
|
|
|
|
DOP20_CURL_OPTS=()
|
|
if [[ "${DOP20_INSECURE:-}" == "1" ]]; then
|
|
DOP20_CURL_OPTS+=("-k")
|
|
echo "Warning: DOP20_INSECURE=1 set — skipping TLS verification." >&2
|
|
fi
|
|
|
|
while IFS= read -r url; do
|
|
[[ -z "$url" || "$url" =~ ^# ]] && continue
|
|
fname="${url##*/}"
|
|
case "$fname" in
|
|
*.jp2) dest="$OUT_JP2/$fname" ;;
|
|
*.j2w) dest="$OUT_J2W/$fname" ;;
|
|
*_meta.xml) dest="$OUT_META/$fname" ;;
|
|
*) echo "Skipping unknown asset type: $fname" >&2; continue ;;
|
|
esac
|
|
if [[ -f "$dest" ]]; then
|
|
echo "Exists: $fname"
|
|
continue
|
|
fi
|
|
echo "Downloading $fname"
|
|
curl -fL "${DOP20_CURL_OPTS[@]}" "$url" -o "$dest"
|
|
done < "$LIST"
|
|
|
|
echo "Done. Files in $OUT_JP2, $OUT_J2W, $OUT_META"
|