Skip to content

Commit

Permalink
Opening support for both Mac and Linux in downloader.sh
Browse files Browse the repository at this point in the history
Closes issue NITDgpOS#21
Display a message when a platform is not supported
  • Loading branch information
Compro Prasad authored and Compro-Prasad committed Oct 6, 2019
1 parent ecc1b42 commit 926241e
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions BASH/downloader.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
index(){
index() {
echo "$(echo $@ | grep -aob '"' | grep -oE '[0-9]+' | sed "${!#};d")"
}

issuesPage="https://github.com/NIT-dgp/manga/issues/new"

os=$(uname)
if [ "$os" = "Linux" -o "$os" = "FreeBSD" ]; then
openWith="$(which xdg-open 2> /dev/null)"
elif [ "$os" = "Darwin" ]; then
openWith="$(which open 2> /dev/null)"
else
echo "Platform '$os' not listed"
echo "PDF will not be automatically opened for you"
echo "Please raise an issue on $issuesPage"
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
Expand All @@ -15,7 +29,6 @@ do
if [ "${!i}" = "-fo" ]; then
x=$i
fi

done
if [ "$t" -ne 0 ]; then
if [ "$c" -gt "$t" ]; then
Expand Down Expand Up @@ -71,7 +84,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 -q -O $i.html -c www.mangareader.net/$manga/$chap/$i # Downloads the main webpage
Expand Down Expand Up @@ -103,9 +116,11 @@ do
echo -e "Your downloaded file is in this path:\n" $path
cd ..
if [ "$x" != "" ]; then
nautilus $path
nautilus $path
else
gnome-open chap$chapno.pdf
rm -rf $chap
if [ -n "$openWith" ]; then
$openWith chap$chapno.pdf
fi
rm -rf $chap
fi
done

0 comments on commit 926241e

Please sign in to comment.