manga_up/manga-downloader.sh

32 lines
1.0 KiB
Bash
Raw Normal View History

2021-06-15 15:47:26 +00:00
#!/bin/env bash
DOWNLOAD_PATH="/srv/dev-disk-by-label-uno/download/comics"
MANGA_FOLDER="/srv/dev-disk-by-label-uno/media/comics/manga/DrStone"
RESULT=$(
manga-py \
--rename-pages \
--cbz \
--reverse-downloading \
--max-volumes 1 \
--print-json \
--cookies "test=1" \
--user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0" \
--destination "$DOWNLOAD_PATH" \
https://www.funmanga.com/dr-stone \
2>/dev/null
)
echo "$RESULT" >manga-py.log
FORMAT="Dr. STONE v"
VOLUMES_DOWNLOADED=$(echo "$RESULT" | jq '.volumes | length')
VOLUME_PATH="$(realpath "$(echo "$RESULT" | jq '.volumes[0].path' | tr -d "\"")")"
CHAPTER_NUMBER=$(echo "$VOLUME_PATH" | grep -Po "[0-9]+")
if [[ "$VOLUMES_DOWNLOADED" -ne 0 ]]; then
apprise --tag "telegram" --title "Manga Download: Dr. Stone" --body "Chapter downloaded: ${CHAPTER_NUMBER}"
mv "$VOLUME_PATH" "${MANGA_FOLDER}/${FORMAT}${CHAPTER_NUMBER}.cbz"
# keep dummy file in place of the downloaded chapter to prevent re-downloading
touch "$VOLUME_PATH"
fi