-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbate
40 lines (34 loc) · 1.11 KB
/
tbate
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
#!/data/data/com.termux/files/usr/bin/bash
GREEN='\033[1;32m'
NC='\033[0m'
RED='\033[0;31m'
CYAN='\033[0;36m'
if [[ ${#TBATE} -eq 0 ]]; then
TBATE="/storage/emulated/0/Books/tbate"
fi
dld() {
ch=$1
data=$( curl -Ls https://lightnovelreader.com/the-beginning-after-the-end-813565/chapter-$ch | pup '#chapterText' )
if [[ ${#data} -gt 0 ]]; then
echo "$data" > "$TBATE/$ch.html"
title=$( echo "$data" | pup ':contains("Chapter '$ch'") text{}' | tr '\n' ' '|awk '{$1=$1};1' )
pandoc -f html -t epub3 --metadata title="$title" -o "$TBATE/$ch.epub" "$TBATE/$ch.html"
rm "$TBATE/$ch.html"
printf "${CYAN}Downloaded${NC} ${GREEN}$ch - $title${NC}\n"
else
printf "${RED}$ch${NC} ${CYAN}Not Released Yet${NC}\n"
fi
}
main() {
if [[ $# -ne 0 ]]; then
for chapter in $@; do
printf "${CYAN}Downloading${NC} ${GREEN}$chapter${NC}\n"
dld $chapter
done
else
chapter=$(( $( ls $TBATE | sort -nr | head -n1 | cut -d. -f1) + 1))
dld $chapter
read -n1 -s -p "Press any key to exit"
fi
}
main $@