Enabled download and alloed arbitrary destination folder for the downloads
This commit is contained in:
parent
72e3427ea9
commit
e2c4cb11ea
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
cookies
|
||||
downloads
|
17
run.sh
17
run.sh
@ -4,19 +4,30 @@ echo 'Loggin in'
|
||||
curl -b cookies -c cookies -s -F 'email=ChristianLupus@web.de' -F 'form_id=packt_user_login_form' -F 'password=naitsirhc' -F 'op=Login' https://www.packtpub.com/ > /dev/null
|
||||
|
||||
echo 'Obtaining free book information'
|
||||
url=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | grep freelearning-claim free.html | grep -o 'href="[^"]*' | grep -o '/free.*')
|
||||
url=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | grep freelearning-claim | grep -o 'href="[^"]*' | grep -o '/free.*')
|
||||
|
||||
echo 'Claiming free book'
|
||||
#curl -b cookies -c cookies https://www.packtpub.com$url
|
||||
curl -b cookies -c cookies https://www.packtpub.com$url
|
||||
|
||||
opwd=$(pwd)
|
||||
if [ $# -eq 1 ]; then
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
else
|
||||
mkdir downloads
|
||||
cd downloads
|
||||
fi
|
||||
|
||||
echo 'Downloading books'
|
||||
id=$(echo $url | grep -o '/[0-9/]*/' | grep -o '[0-9]*')
|
||||
#curl -b cookies -c cookies -J -O https://www.packtpub.com/ebook_download/$id/pdf
|
||||
#curl -b cookies -c cookies -J -O https://www.packtpub.com/ebook_download/$id/epub
|
||||
out=$(curl -b cookies -c cookies -J -O -O https://www.packtpub.com/ebook_download/$id/pdf https://www.packtpub.com/ebook_download/$id/epub 2>&1 )
|
||||
out=$(curl -b "$opwd/cookies" -c "$opwd/cookies" -J -O -O https://www.packtpub.com/ebook_download/$id/pdf https://www.packtpub.com/ebook_download/$id/epub 2>&1 )
|
||||
|
||||
ret=$?
|
||||
|
||||
cd "$opwd"
|
||||
|
||||
echo 'Logging off'
|
||||
curl -b cookies -c cookies -s https://www.packtpub.com/logout > /dev/null
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user