-
Notifications
You must be signed in to change notification settings - Fork 0
/
videos.sh
executable file
·74 lines (61 loc) · 1.66 KB
/
videos.sh
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
#!/bin/bash -eu
set -o pipefail
FILE=${FILE:-}
FILES_REPO=${FILES_REPO:-../files001.git}
FILES_SLUG=${FILES_SLUG:-$(basename "$FILES_REPO" .git)}
OUTPUT_DIR=${OUTPUT_DIR:-mp4}
VOIDSTAR_REPO=${VOIDSTAR_REPO:-https://github.com/voidstarHQ/voidstar.git}
echo FILE "$FILE"
echo FILES_REPO "$FILES_REPO"
echo FILES_SLUG "$FILES_SLUG"
echo OUTPUT_DIR "$OUTPUT_DIR"
echo VOIDSTAR_REPO "$VOIDSTAR_REPO"
run() {
local file=$1; shift
echo file "$file"
[[ "$file" =~ ^[0-9a-f]{64}. ]] || return 2
out="$OUTPUT_DIR"/"$file".mp4
echo out "$out"
[[ -f "$out" ]] && return 2
tmp=$(mktemp --directory --quiet)
url=https://github.com/voidstarHQ/"$FILES_SLUG"/raw/main/"$file"
echo url "$url"
args=()
args+=(build)
args+=(--output="$tmp"/)
args+=(--target=video-gcc)
args+=(--build-arg=FILE="$url")
args+=(--build-arg=WxHxD=800x800x24)
if [[ "$VOIDSTAR_REPO" =~ ^https: ]]; then
args+=("$VOIDSTAR_REPO")
else
[[ -d "$VOIDSTAR_REPO" ]] || return 1
args+=(-f "$VOIDSTAR_REPO"/Dockerfile)
args+=("$VOIDSTAR_REPO")
fi
DOCKER_BUILDKIT=1 docker "${args[@]}" || return 1
mv "$tmp"/video.mp4 "$out"
}
if [[ -n "$FILE" ]]; then
run "$FILE"
exit
fi
url=https://api.github.com/repos/VoidstarHQ/"$FILES_SLUG"/git/trees/main
echo url "$url"
errors=0
for file in $(curl -fsSL# "$url" \
| jq -r '.tree[]|.path' \
| sort -u \
); do
set +o errexit
run "$file"
failed=$?
set -o errexit
case $failed in
0) ;;
1) ((errors++)) || true ;;
2) continue ;;
esac
done
exit "$errors"
# https://adw0rd.github.io/instagrapi/usage-guide/media.html