1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/usr/bin/env bash
# Download the recent macOS Aerial pack (Tahoe / Sequoia / Sonoma / Cazadero)
# from Apple's public catalog, then optionally encode to lite 1080p24.
#
# Usage:
# fetch-aerial-recent # download masters only
# fetch-aerial-recent --encode # download + encode-aerial-lite
#
# Note: recent Tahoe/Sequoia/Sonoma clips are 4K@240. On a ThinkPad T480,
# prefer install-aerial-videos --from-zip aerial-videos-lite.zip instead.
set -euo pipefail
ENCODE=0
for arg in "$@"; do
case "$arg" in
--encode) ENCODE=1 ;;
-h|--help)
echo "Usage: fetch-aerial-recent [--encode]"
exit 0
;;
esac
done
MASTER_DIR="${AERIAL_MASTER_DIR:-$HOME/Videos/Screensavers/Aerial-masters}"
LITE_DIR="${DST_DIR:-$HOME/Videos/Screensavers/Aerial}"
CATALOG_DIR="${TMPDIR:-/tmp}/aerial-catalog-$$"
CONFIG_URL="https://configuration.apple.com/configurations/internetservices/aerials/resources-config-26-0.plist"
WANT_LABELS=(
"Tahoe Day" "Tahoe Morning" "Tahoe Evening" "Tahoe Night"
"Sequoia Sunrise" "Sequoia Morning" "Sequoia Night"
"Cazadero"
"Sonoma Evening" "Sonoma Clouds" "Sonoma from Above" "Sonoma River"
)
need() { command -v "$1" >/dev/null 2>&1 || { echo "Missing dependency: $1" >&2; exit 1; }; }
need curl
need python3
need aria2c
need tar
mkdir -p "$MASTER_DIR" "$CATALOG_DIR"
trap 'rm -rf "$CATALOG_DIR"' EXIT
echo "Resolving macOS Aerial catalog..."
RESOURCES_URL="$(curl -fsSL --max-time 30 "$CONFIG_URL" | python3 -c '
import sys,re
text=sys.stdin.read()
m=re.search(r"<key>resources-url</key>\s*<string>([^<]+)</string>", text)
if not m: raise SystemExit("resources-url not found in plist")
print(m.group(1))
')"
echo "Catalog: $RESOURCES_URL"
curl -kfsSL --max-time 120 -o "$CATALOG_DIR/resources.tar" "$RESOURCES_URL"
tar -xf "$CATALOG_DIR/resources.tar" -C "$CATALOG_DIR" 2>/dev/null || true
ENTRIES_JSON="$(find "$CATALOG_DIR" -name entries.json -type f | head -n1)"
if [[ -z "$ENTRIES_JSON" ]]; then
echo "entries.json not found in catalog tar" >&2
exit 1
fi
python3 - "$ENTRIES_JSON" "$CATALOG_DIR/urls.txt" <<'PY'
import json, os, sys
entries_path, urls_path = sys.argv[1], sys.argv[2]
want = {
"Tahoe Day", "Tahoe Morning", "Tahoe Evening", "Tahoe Night",
"Sequoia Sunrise", "Sequoia Morning", "Sequoia Night",
"Cazadero",
"Sonoma Evening", "Sonoma Clouds", "Sonoma from Above", "Sonoma River",
}
data = json.load(open(entries_path, encoding="utf-8"))
found = []
with open(urls_path, "w", encoding="utf-8") as out:
for asset in data.get("assets", []):
label = asset.get("accessibilityLabel") or ""
if label not in want:
continue
url = asset.get("url-4K-SDR-240FPS") or asset.get("url-4K-SDR")
if not url:
continue
base = os.path.basename(url.split("?", 1)[0])
out.write(f"{url}\n out={base}\n")
found.append((label, base))
if len(found) != len(want):
missing = want - {l for l, _ in found}
print(f"warning: missing labels: {sorted(missing)}", file=sys.stderr)
print(f"Queued {len(found)} clips:")
for label, base in sorted(found):
print(f" {label}: {base}")
PY
echo
echo "Downloading into $MASTER_DIR ..."
aria2c --check-certificate=false -c -x 4 -s 4 -j 3 \
-i "$CATALOG_DIR/urls.txt" \
-d "$MASTER_DIR" \
--auto-file-renaming=false
echo
echo "Masters ready: $(du -sh "$MASTER_DIR" | cut -f1)"
if [[ "$ENCODE" -eq 1 ]]; then
SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
ENCODER="$SCRIPT_DIR/encode-aerial-lite"
if [[ ! -x "$ENCODER" ]]; then
ENCODER="$(command -v encode-aerial-lite || true)"
fi
if [[ -z "$ENCODER" ]]; then
echo "encode-aerial-lite not found; masters left in $MASTER_DIR" >&2
exit 1
fi
DST_DIR="$LITE_DIR" "$ENCODER" "$MASTER_DIR"
fi
echo "Done."
|