blob: 5e6b313d2da2e990142d1c15298a98bc560585d0 (
plain)
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
|
#!/usr/bin/env bash
# Install Aerial lite clips into ~/Videos/Screensavers/Aerial.
#
# Modes:
# install-aerial-videos # download from Apple + encode
# install-aerial-videos --from-zip FILE.zip # unpack a LocalSend video pack
# install-aerial-videos --from-dir DIR # copy already-lite .mp4 files
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VIDEO_DIR="${VIDEO_DIR:-$HOME/Videos/Screensavers/Aerial}"
MODE="fetch"
FROM=""
usage() {
cat <<EOF
Usage:
install-aerial-videos Download recent Apple pack and encode
install-aerial-videos --from-zip ZIP Install from aerial-videos-lite.zip
install-aerial-videos --from-dir DIR Copy .mp4/.mov/.mkv from DIR
Dest: $VIDEO_DIR
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--from-zip)
MODE="zip"
FROM="${2:-}"
shift 2
;;
--from-dir)
MODE="dir"
FROM="${2:-}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
done
mkdir -p "$VIDEO_DIR"
case "$MODE" in
zip)
[[ -n "$FROM" && -f "$FROM" ]] || { echo "ZIP not found: $FROM" >&2; exit 1; }
echo "Installing videos from $FROM -> $VIDEO_DIR"
# Accept either flat mp4s or a single top-level folder of mp4s
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
unzip -q -o "$FROM" -d "$tmp"
mapfile -t files < <(find "$tmp" -type f \( -iname '*.mp4' -o -iname '*.mov' -o -iname '*.mkv' \) | sort)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No videos inside zip" >&2
exit 1
fi
for f in "${files[@]}"; do
install -m 0644 "$f" "$VIDEO_DIR/$(basename "$f")"
done
echo "Installed ${#files[@]} clips ($(du -sh "$VIDEO_DIR" | cut -f1))"
;;
dir)
[[ -n "$FROM" && -d "$FROM" ]] || { echo "DIR not found: $FROM" >&2; exit 1; }
echo "Copying videos from $FROM -> $VIDEO_DIR"
count=0
while IFS= read -r -d '' f; do
install -m 0644 "$f" "$VIDEO_DIR/$(basename "$f")"
count=$((count + 1))
done < <(find "$FROM" -maxdepth 1 -type f \( -iname '*.mp4' -o -iname '*.mov' -o -iname '*.mkv' \) -print0 | sort -z)
echo "Installed $count clips ($(du -sh "$VIDEO_DIR" | cut -f1))"
;;
fetch)
need() { command -v "$1" >/dev/null 2>&1 || { echo "Missing dependency: $1" >&2; exit 1; }; }
need curl
need aria2c
need ffmpeg
FETCH="$ROOT/bin/fetch-aerial-recent"
[[ -x "$FETCH" ]] || FETCH="$(command -v fetch-aerial-recent)"
echo "Fetching + encoding recent Apple Aerial pack (needs network)..."
echo "On a ThinkPad T480 this can take a while; prefer --from-zip if you have the video pack."
DST_DIR="$VIDEO_DIR" "$FETCH" --encode
;;
esac
echo "Video dir: $VIDEO_DIR"
ls -lh "$VIDEO_DIR"
|