33 lines
917 B
Bash
Executable File
33 lines
917 B
Bash
Executable File
#!/bin/sh
|
|
|
|
#you probably have these already:
|
|
# grep, awk, basename, printf
|
|
#
|
|
#optional: pv ("Pipe Viewer")
|
|
|
|
#set to 1 to enable, anything else to disable using pv to monitor downloading
|
|
#pv is nice so you can see download speed and whatnot, instead of just "start/stop"
|
|
use_pv=1
|
|
#use_pv=1
|
|
|
|
target_dir="konpeito"
|
|
mkdir -p "$target_dir"
|
|
|
|
gemini_get(){ ./gemini_get_openssl.sh "$@";}
|
|
|
|
gemini_get "gemini://konpeito.media/"|tee "$target_dir/index.gmi"|
|
|
grep "^=>"|awk "{print \$2}"|
|
|
while read -r i;do
|
|
file="$(basename "$i")"
|
|
gemini_get "$i"|tail -n +2|
|
|
if [ "$use_pv" = "1" ];then
|
|
pv -rtN "$file"
|
|
else
|
|
printf "%s" "started $file" >&2
|
|
cat
|
|
printf "\x1b[999D%s\n" "finished $file" >&2 #CSI escape sequence to move cursor to the start of line
|
|
#avoids having both a start AND stop line per file
|
|
fi >"$target_dir/$file" #redirects both pv and cat ;P
|
|
sleep 0.1
|
|
done
|