diff --git a/BASH/downloader.sh b/BASH/downloader.sh index 9b769bf..83bad73 100644 --- a/BASH/downloader.sh +++ b/BASH/downloader.sh @@ -1,6 +1,14 @@ -index(){ +index() { echo "$(echo $@ | grep -aob '"' | grep -oE '[0-9]+' | sed "${!#};d")" } + +os=$(uname) +if [ "$os" = "Linux" -o "$os" = "FreeBSD" ]; then + openWith="xdg-open" +elif [ "$os" = "Darwin" ]; then + openWith="open" +fi + a="$#" declare -i chaps=0,chape=0,t=0,c=0,end_loop=0,d1=0,d2=0 #checking for existence of -t , --chap in argument @@ -65,7 +73,7 @@ do fi rm index.html declare -i i=1 - while true #an infinte while loop + while true #an infinite while loop do echo "Downloading page $i of chapter $chap....." wget -o log.txt -O $i.html -c www.mangareader.net/$manga/$chap/$i # Downloads the main webpage @@ -96,6 +104,6 @@ do path=$(pwd) echo -e "Your downloaded file is in this path:\n" $path cd .. - xdg-open chap$chapno.pdf + $openWith chap$chapno.pdf rm -rf $chap done