Skip to content

Instantly share code, notes, and snippets.

@leober-ramos33
Last active July 31, 2019 02:41
Show Gist options
  • Save leober-ramos33/5ab1b84bdd57ed0fedda76c41a33ee03 to your computer and use it in GitHub Desktop.
Save leober-ramos33/5ab1b84bdd57ed0fedda76c41a33ee03 to your computer and use it in GitHub Desktop.
A script for download manga from submanga.online
# manga.sh
# A script for download manga from submanga.online
# By: @yonaikerlol
if [ -z "$1" ]; then
echo "[Error] Required a manga"
exit 1
fi
if ! command -v curl &> /dev/null; then
echo "[Error] Curl is required"
echo -e "\tInstall it with: 'apt-get install curl'"
exit 1
fi
manga="${1}"
url="https://submanga.online/manga/${manga}"
echo "Extracting '${manga}'..."
chapters=$(curl -Ls "${url}" | grep -Eo "${url}/[0-9]{1,}" | sort -u | wc -l)
echo -e "\tChapters: ${chapters}"
for (( i=1; i <= chapters; i++ )); do mkdir -p "${manga}/${i}"; done
for (( chapter=1; chapter <= chapters; chapter++ )); do
echo -e "\n\tExtracting chapter '${chapter}'..."
pages=$(curl -Ls "${url}/${chapter}" | grep -Eo "https://submanga.online/uploads/manga/${manga}/chapters/${chapter}/[0-9]{1,}.jpg" | sort -u | wc -l)
echo -e "\t\tPages: ${pages}"
files=()
for (( page=1; page <= pages; page++ )); do
if [ $page -lt 10 ]; then
{
curl -Lsf "https://submanga.online/uploads/manga/${manga}/chapters/${chapter}/0${page}.jpg" -o "${manga}/${chapter}/0${page}.jpg"
} || {
curl -Ls "https://submanga.online/uploads/manga/${manga}/chapters/${chapter}/${page}.jpg" -o "${manga}/${chapter}/0${page}.jpg"
}
files+=("${manga}/${chapter}/0${page}.jpg")
else
curl -Ls "https://submanga.online/uploads/manga/${manga}/chapters/${chapter}/${page}.jpg" -o "${manga}/${chapter}/${page}.jpg"
files+=("${manga}/${chapter}/${page}.jpg")
fi
done
if command -v jpegoptim &> /dev/null; then
jpegoptim -q ${files[*]}
fi
if command -v convert &> /dev/null; then
convert -quiet ${files[*]} "${manga}/${chapter}.pdf"
rm -rf "${manga}/${chapter}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment