-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmake-json
executable file
·65 lines (58 loc) · 1.09 KB
/
make-json
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
#!/usr/bin/env bash
#
# Convert the list of episodes into JSON format
#
# Author: Dave Eddy <[email protected]>
# Date: March 17, 2024
# License: MIT
. ./util || exit 1
typ=$1
[[ -n $typ ]] || exit 1
objects=()
callback() {
local _num=$1
local title=$2
local desc=$3
local link=$4
local tt=$5
local yt=$6
local ig=$7
# this is an "episode" object in the final json
local json
read -d '' -r json <<-"EOF"
{
"title": $title,
"desc": $desc,
"link": $link,
"external": {
"tiktok": $tiktok,
"youtube": $youtube,
"instagram": $instagram
}
}
EOF
local object
object=$(jq -c --null-input \
--arg title "$title" \
--arg desc "$desc" \
--arg link "$link" \
--arg tiktok "$tt" \
--arg youtube "$yt" \
--arg instagram "$ig" \
"$json"
) || exit
objects+=("$object")
}
foreach-video "$typ" callback
now=$(date +%s)
printf '%s\n' "${objects[@]}" | jq -n \
--arg site "https://$SITE" \
--arg typ "$typ" \
--argjson date "$now" \
'{
"name": "You Suck at Programming",
"site": $site,
"generated": $date,
"type": $typ,
"episodes": [inputs]
}'