Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Madokami auto-downloader by Huntereb
- #Simply fill in the variables at the top with your information
- #Use cron or some kind of scheduler to automate the downloading of files
- #Directory to put our mangas
- dlDir="/home/user/downloads/manga"
- #Username for madokami
- userN="Username"
- #Password for madokami
- passW="Password"
- #The root directory for each manga you want to download (separate multiple with spaces)
- ourMangu=(https://manga.madokami.com/Manga/mangu1 https://manga.madokami.com/Manga/mangu2)
- #---------------------------------------------------------------------------Don't edit anything below here!
- urldecode() {
- local url_encoded="${1//+/ }"
- printf '%b' "${url_encoded//%/\\x}"
- }
- RED='\033[0;31m'
- NC='\033[0m'
- ourDomain="https://manga.madokami.com"
- if [ ! -d "$dlDir" ]; then
- echo -e ""$RED"The directory \""$dlDir"\" does not exist; exiting.$NC"
- exit 0
- fi
- if [ ! "$userN" ] || [ ! "$passW" ]; then
- echo -e ""$RED"A username and password is required to access Madokami; exiting.$NC"
- exit 0
- fi
- for currentMangu in "${ourMangu[@]}"
- do
- IFS=$'\n'
- wget -l 0 --user $userN --password $passW $currentMangu -O "$dlDir"/current
- if [ $? -gt 0 ]; then
- echo -e "$RED"$currentMangu" is not a valid Manga, or you entered an invalid username/password; skipping.$NC"
- rm "$dlDir"/current
- continue
- fi
- foundTitles=($(grep --null "rel=\"nofollow\">" "$dlDir"/current))
- ourName=($(grep --null "class=\"title\"" "$dlDir"/current))
- IFS=$'<>'
- if [ ! "$ourName" ]; then
- IFS=$'/'
- read -r -a ourName <<< "$currentMangu"
- ourName=$(urldecode ${ourName[-1]})
- else
- read -r -a ourName <<< "$ourName"
- ourName="${ourName[-2]}"
- fi
- rm "$dlDir"/current
- if [ ! -d "$dlDir"/"$ourName" ]; then
- mkdir "$dlDir"/"$ourName"
- fi
- for i in "${foundTitles[@]}"
- do
- IFS=$'\"'
- read -r -a ourFile <<< "$i"
- IFS=$'<>'
- read -r -a ourLocalFile <<< "$i"
- IFS=$'.<'
- read -r -a ourLocalFileExt <<< "$i"
- IFS=$'\n'
- if [ "${ourLocalFileExt[-2]}" = "zip" ]; then
- ourLocalFile="${ourLocalFile[-2]::-3}cbz"
- elif [ "${ourLocalFileExt[-2]}" = "rar" ]; then
- ourLocalFile="${ourLocalFile[-2]::-3}cbr"
- else
- echo -e "$REDUnexpected file type; skipping.$NC"
- continue
- fi
- if [ ! -f "$dlDir"/"$ourName"/"$ourLocalFile" ]; then
- wget -l 0 --user $userN --password $passW "$ourDomain""${ourFile[1]}" -O ""$dlDir"/"$ourName"/"$ourLocalFile""
- else
- echo -e "$RED"$ourLocalFile" already exists; skipping.$NC"
- fi
- done
- done
- exit 0
Add Comment
Please, Sign In to add comment