-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtachi-tog
49 lines (41 loc) · 1.31 KB
/
tachi-tog
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
#!/data/data/com.termux/files/usr/bin/bash
GREEN='\033[1;32m'
NC='\033[0m'
RED='\033[0;31m'
CYAN='\033[0;36m'
URL="https://kaminotou.com/manga/tower-of-god-manga-chapter-"
TOG="/storage/emulated/0/TachiyomiJ2K/local/Tower Of God"
dld_tog(){
chap_dir="$TOG/$1"
results=$( curl -s "$URL$1" |
pup 'img.aligncenter[data-lazy-src"] attr{data-lazy-src}' )
if [[ ${#results} -eq 0 ]];then
echo "Not Released Yet"
exit 0;
fi
if [ ! -d "$chap_dir" ]; then
mkdir "$chap_dir"
fi
cd "$chap_dir"
printf "${CYAN}Total Images:${NC} ${GREEN}$( echo $results | tr " " "\n" | wc -l )${NC}\n"
echo ${results} | tr " " "\n" | parallel -j8 "wget -q {} && printf '${GREEN}•${NC}' || printf '${RED}•${NC}'"
echo
}
main() {
if [[ $# -eq 0 ]]; then
extra=$(( $( ls "$TOG" | wc -l ) - 2 ))
if [[ $extra -ne 0 ]]; then
printf "Deleting ${RED}$extra${NC} Previous Chapters\n"
fi
ls "$TOG" | sort | head -n$extra | xargs -i{} rm -rf "$TOG/{}"
ch=$(( $( ls "$TOG" | sort -nr | head -n1 ) + 1 ))
dld_tog $ch
read -n1 -s -p "Press any key to exit"
else
for chapter in $@; do
printf "${CYAN}Downloading${NC} ${GREEN}$chapter${NC}\n"
dld_tog $chapter
done
fi
}
main $@