forked from bahamas10/ysap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-episodes
More file actions
executable file
·76 lines (61 loc) · 1.45 KB
/
Copy pathmake-episodes
File metadata and controls
executable file
·76 lines (61 loc) · 1.45 KB
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
#!/usr/bin/env bash
#
# Generate the page as seen by `curl ysap.sh/episodes`
#
# Author: Dave Eddy <dave@daveeddy.com>
# Date: March 17, 2024
# License: MIT
. ./theme || exit
format() {
local num title desc link _tt _yt _ig
while IFS=$'\t' read -r num title desc link _tt _yt _ig; do
title=$(format-title "$num" "$title")
desc=$(format-description "$desc")
link=$(format-link "$link")
printf '%s\t%s\t%s\n' \
"$title" \
"$desc" \
"$link"
done
}
format-title() {
local num=$1
local name=$2
printf -v num '%2d' "$num"
echo "$COLOR4$num. $RST$COLOR3$name$RST"
}
format-description() {
local desc=$1
format-ticks "$desc"
}
format-link() {
local link=$1
echo "${COLOR1}https://ysap.sh$link$RST"
}
format-ticks() {
local text=$1
local colors=("$COLOR5" "$COLOR2")
local index=0
local new_s=${colors[index]}
local i c
for ((i = 0; i < ${#text}; i++)); do
c=${text:i:1}
if [[ $c == '`' ]]; then
index=$(((index + 1) % 2))
new_s+="$RST${colors[index]}"
else
new_s+=$c
fi
done
new_s+=$RST
printf '%s' "$new_s"
}
# create the header
./make-header -p 7 |
./tools/box -hp 4 -T plain |
./tools/rtrim-ansi-aware
echo
# create the table
./make-list | \
format | \
./tools/box -s $'\t' -hp 1 -tc "$COLOR5" -bc "$COLOR4" -t Episodes -vp 1