-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.sh
executable file
·50 lines (40 loc) · 1.22 KB
/
run.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
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
script_dir="$(dirname $0)"
cd $script_dir
input_queue="$PWD/input.txt"
workspace_root="$PWD/generate-assets/workspace"
done_dir="$PWD/generate-assets/done"
bucket_root="gs://tiktok-video-assets"
bucket="$bucket_root/video-assets"
session="session-$(date +%Y-%m-%d_%H-%M-%S)"
mkdir -p $workspace_root
curl -A 'random' -v 'https://old.reddit.com/r/AmItheAsshole/top.json?t=week' | jq -r '.data.children[] | .data | .url' | grep -v update | grep -Pv "^$" | head -n100 | shuf -n2 > $input_queue
cat $input_queue
video_urls=$(cat $input_queue)
for video_url in $video_urls
do
(
cd generate-assets/
python3 run.py $video_url
)
done
for name in $(ls $workspace_root); do
workdir="$workspace_root/$name"
gsutil -m cp -r $workdir $bucket
filename="$(cat $workdir/script.json | jq -r '.title | .filename')"
video=$workdir/$filename
export REMOTION_PROJECT_ID=$name
(
cd video-generator/
npx remotion render src/index.tsx Main $video
echo $video
gsutil cp $video $bucket_root/videos/$session/
)
mv -f $workdir $done_dir
done
echo "Session done: $session"
echo > $input_queue
curl metadata.google.internal -i && poweroff