Skip to content

Commit

Permalink
Update and rename xtest.sh to run.sh
Browse files Browse the repository at this point in the history
removed uses of curl to reduce the amount of needed programs to a minimum, choosing to keep wget for included file name decoding from url
  • Loading branch information
idolmatster authored Oct 17, 2020
1 parent cdbf44c commit 9d55d31
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xtest.sh → run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/dash

exit_here(){
echo "this doujin seems to not exist, if it exists leave an issue on github or message Zhāng Jūn 张军#8497"
echo "this doujin seems to not exist, if it exists leave an issue on github or message Zhāng Jūn 张军#8497 on Discord"
exit 0
}

#gather doujin info
doujin=$(curl -s "https://nhentai.net/api/gallery/$1")
doujin=$(wget -qO- "https://nhentai.net/api/gallery/$1")
media_id=$(echo $doujin | jq -r '.media_id' || echo "please install jq")
[ "${media_id}" = "null" ] && exit_here
page_count=$(echo $doujin | jq '.images.pages | length ')
Expand All @@ -17,15 +17,18 @@ name=$(echo $doujin | jq -r '.title.pretty')
mkdir $id
cd $id

echo "downloading ${id}"

#DL
for I in `seq 1 $page_count`
do
url="https://i.nhentai.net/galleries/$media_id/$I.jpg"
alturl="https://i.nhentai.net/galleries/$media_id/$I.png"
wget -q ${url} || wget -q ${alturl}
printf "."
done


echo ""

#oneliner lmao https://stackoverflow.com/a/3672383
ls | awk '/^([0-9]+)\.jpg$/ { printf("%s %05d.jpg\n", $0, $1) }' | xargs -n2 mv
Expand Down Expand Up @@ -58,4 +61,3 @@ cd $_cwd

#move zip top dir
mv "$id.zip" ..

0 comments on commit 9d55d31

Please sign in to comment.