Files
repos_scripts/nsfw
2022-02-19 15:22:26 +05:30

23 lines
770 B
Bash
Executable File

#!/bin/sh
[ -z "$*" ] && printf "enter(paste) number or link:" && read -r num || num=$*
num=$(printf "$num" | cut -d\/ -f5)
dir="$HOME/.cache/$num"
mkdir -pv $dir
trap "rm -rf $dir;exit 0" INT HUP
pg=$(curl -s "https://nhentai.net/g/$num/1/" | sed -nE 's/.*pages">(.*)<\/span><.*/\1/p')
echo "pages : $pg"
for i in $(seq $pg);do
url=$(curl -s "https://nhentai.net/g/$num/$i/" | sed -nE 's/.*<img src="([^"]*)".*/\1/p')
i_t=$(printf "%03d" $i)
echo "downloading page $i($url)"
setsid -f curl -s "$url" -o "$dir/$i_t"
sleep 2
done
echo "waiting 5 sec for pages to download completely"
sleep 5
echo "concatenating pages to pdf"
convert "$dir/*" "$num.pdf" && printf "saved pdf as $num.pdf\nopening pdf...enjoy 😏😏" && setsid -f xdg-open "$num.pdf"
rm -rvf $dir