#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"

mkdir -p images/al_green

fetch() {
  local out="$1"
  local url="$2"
  echo "Downloading: $out"
  curl -L --fail --retry 3 --connect-timeout 10 --max-time 180 -o "$out" "$url"
}

# Sources: Wikimedia Commons "Special:FilePath" direct file links.
fetch "images/al_green/ag01_2008.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%202008.jpg"
fetch "images/al_green/ag02_toppop_1973_01.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%20-%20TopPop%201973%2001.jpg"
fetch "images/al_green/ag03_toppop_1973_02.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%20-%20TopPop%201973%2002.jpg"
fetch "images/al_green/ag04_toppop_1973_03.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%20-%20TopPop%201973%2003.jpg"
fetch "images/al_green/ag05_toppop_1973_04.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%20-%20TopPop%201973%2004.jpg"
fetch "images/al_green/ag06_kennedy_center_2010.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%202010%20Kennedy%20Center%20Honors.jpg"
fetch "images/al_green/ag07_2017.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%202017.jpg"

# Album covers (Commons file names can include punctuation; keep URL-encoding).
fetch "images/al_green/ag08_lets_stay_together.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Al%20Green%20-%20Let%27s%20Stay%20Together.jpg"
fetch "images/al_green/ag09_call_me_album.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/Call%20Me%20%28Al%20Green%20album%29.jpg"
fetch "images/al_green/ag10_im_still_in_love_with_you_album.jpg" "https://commons.wikimedia.org/wiki/Special:FilePath/I%27m%20Still%20in%20Love%20with%20You%20%28Al%20Green%20album%29.jpg"

echo "Done. Al_Green.html is configured to use local files under images/al_green/."

