Advertisement
mosaid

manga.sh

Dec 23rd, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. #!/bin/bash
  2. if [[ -z "$1" ]] ; then
  3.     echo "usage `basename "$0" ` <manga title>"
  4.     exit 0
  5. fi
  6. myDIR="/home/$USER/Pictures/$1"
  7. manga=$( echo "$1" | sed 's/^ //' | sed 's/ /-/g' )
  8. link="http://www.mangapanda.com/$manga"
  9. useragent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
  10. nbChapters=$( wget -e robots=off --user-agent "$useragent" -qO - "$link" | sed 's/</\n</g' | grep  -A 3 'class="chico_manga"' | tail -1| sed 's/<[^>]*>//' | tr -dc '0-9' )
  11. for (( chapter=1; chapter<=$nbChapters; chapter++ )) ; do  
  12.     nbPages=$(wget -e robots=off --user-agent "$useragent" -qO - "$link/$chapter" | sed 's/</\n</g' | grep '</select> of ' | tr -dc '0-9')
  13.     let "nbPages +=1"
  14.     echo "downloading chapter $chapter / $nbChapters       "
  15.     for (( i=1; i < $nbPages ; i++ )) ; do
  16.         if ! [ -f "$myDIR/$chapter/$i.png"  ] ; then
  17.             imageLink=$(wget -e robots=off --user-agent "$useragent" -qO - "$link/$chapter/$i" | sed 's/</\n</g' | grep '<img id="img" '  )
  18.             index=$(expr index "$imageLink"   'src' )
  19.             let "index +=4"
  20.             imageLink=${imageLink:$index}
  21.             imageLink=$(echo $imageLink | cut -d'"' -f 1 )
  22.             echo -ne "\t downloading  $i of $nbPages       "\\r
  23.             curl  -s -S  "$imageLink"   --create-dirs -o "$myDIR/$chapter/$i.png"
  24.         fi
  25.     done
  26.     echo -en "\e[1A"   #When you want to go N lines up, use \e[<N>A.
  27. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement