47 lines
1.9 KiB
Bash
Executable File
47 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Dependencies: cut wget curl printf
|
|
# "error.log" will list all download and convert errors
|
|
|
|
# Set time file for sorting text
|
|
downloadtemp="$(mktemp)"
|
|
sortingtemp="$(mktemp)"
|
|
|
|
useragent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36'
|
|
|
|
# Follow given url to final destination
|
|
url=$(curl -s -L -I -o /dev/null -w '%{url_effective}' "$1")
|
|
|
|
toonname=$(echo $url | cut -d'/' -f6)
|
|
episodeno=$(echo $url | cut -d'=' -f3)
|
|
eipsodename=$(echo $url | cut -d'/' -f7)
|
|
pictureno=0
|
|
mkdir -p "$toonname/${toonname}_$(printf %03d $episodeno)"
|
|
|
|
wget --quiet -O "$downloadtemp" "$url"
|
|
if [ ! $? -eq 0 ]; then
|
|
echo -e "Error:\tURL: $url\t(404? This may not be an issue, check the output.)" >> "$toonname/error.log"
|
|
exit 1
|
|
fi
|
|
|
|
grep 'rel="nofollow" ondragstart="return false;" onselectstart="return false;" oncontextmenu="return false;"' "$downloadtemp" > "$sortingtemp"
|
|
|
|
echo -e "\nChapter URL: $url"
|
|
|
|
while read i; do
|
|
pictureno=$((pictureno+1))
|
|
imageurl=$(echo "$i" | cut -d'"' -f12 | cut -d'?' -f1) # Cut out the indervidual image urls
|
|
wget --no-verbose --tries=6 --user-agent="$useragent" --referer="http://www.webtoons.com/" "$imageurl" -O "$toonname/${toonname}_$(printf %03d $episodeno)/${toonname}_$(printf %03d $episodeno)_$(printf %03d $pictureno).jpg" || echo "URL: $imageurl Name: $toonname/${toonname}_$(printf %03d $episodeno)/${toonname}_$(printf %03d $episodeno)_$(printf %03d $pictureno).jpg" >> "$toonname/error.log"
|
|
done < "$sortingtemp"
|
|
|
|
# Remove the last image if it is the webtoon logo
|
|
#mv "$toonname/temp/${toonname}_$(printf %03d $episodeno)_$(printf %03d $pictureno).jpg" "$toonname/temp/logo/${toonname}_$(printf %03d $episodeno)_$(printf %03d $pictureno).jpg"
|
|
|
|
if [ -f "$toonname/error.log" ]; then
|
|
echo "Error log:"
|
|
cat "$toonname/error.log"
|
|
fi
|
|
|
|
# Remove temp file
|
|
rm "$sortingtemp" "$downloadtemp"
|