Skip to content

Instantly share code, notes, and snippets.

@vtmx
Created August 2, 2026 15:59
Show Gist options
  • Select an option

  • Save vtmx/05af3e6e2dc69bc551ddf051c051cb77 to your computer and use it in GitHub Desktop.

Select an option

Save vtmx/05af3e6e2dc69bc551ddf051c051cb77 to your computer and use it in GitHub Desktop.
mangadow
#!/usr/bin/env bash
set -euo pipefail
# https://mangalivre.to/manga/kimetsu-no-yaiba/capitulo-{1..150}/
# Check pre-requisites
prereqs=(curl ebook-convert magick wget)
for pkg in "${prereqs[@]}"; do
if ! command -v $pkg &>/dev/null; then
if [[ $pkg == 'ebook-convert' ]]; then
echo "error: need install calibre"
else
echo "error: need install $pkg"
fi
exit 1
fi
done
# Variables
url_base='https://mangalivre.to'
manga_title='kimetsu-no-yaiba'
authors="Koyoharu Gotoge"
chapter_start=101
chapter_end=110
echo
# Download imagens
for ((chapter=$chapter_start; chapter<=$chapter_end; chapter++)); do
chapter_number=$(printf "%03d" $chapter)
manga_dir="$(pwd)/$manga_title"
chapter_dir="$manga_dir/$chapter_number"
echo "Create dir $(pwd)/$chapter_dir"
[[ -d "$chapter_dir" ]] && rm -r "$chapter_dir"
mkdir -p "$chapter_dir"
manga_url="$url_base/manga/$manga_title/capitulo-${chapter}/"
echo -e "Download fom: $manga_url\nTo: $(pwd)/$chapter_dir"
wget -q -N -P "$chapter_dir" \
$(curl "$manga_url" | grep -Eo "$url_base/wp-content/uploads/WP-manga/data.+.webp")
echo 'Converting webp to html...'
manga_file_html="$manga_dir/$manga_title-$chapter_number.html"
manga_file_mobi="$manga_dir/$manga_title-$chapter_number.mobi"
echo -e "<html>\n\t<body style=\"background: black\">" > "$manga_file_html"
for img in "$chapter_dir"/*.webp; do
echo -e "\t\t<img style=\"display: block; margin: 0 auto; width: 100%; height: auto\" src=\"$img\">" >> "$manga_file_html"
done
echo -e "\t</body>\n</html>" >> "$manga_file_html"
echo Convert cover image...
manga_cover_webp=$(ls $chapter_dir/*.webp | head -n1)
manga_cover_png="${manga_cover_webp/webp/png}"
magick "$manga_cover_webp" "$manga_cover_png"
echo 'Converting to html to mobi...'
ebook-convert "$manga_file_html" "$manga_file_mobi" \
--title "$manga_title-$chapter_number" \
--authors "$authors" \
--publisher "Mangá Livre" \
--language "pt_BR" \
--cover "$manga_cover_png" \
--extra-css "style.css"
echo "Removing $manga_file_html"
rm "$manga_file_html"
echo "Removing dir $chapter_dir"
rm -r "$chapter_dir"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment