Modified code to download newly named files
This commit is contained in:
parent
e2c4cb11ea
commit
fa607357b5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
cookies
|
||||
downloads
|
||||
*~
|
||||
|
9
run.sh
9
run.sh
@ -14,15 +14,15 @@ if [ $# -eq 1 ]; then
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
else
|
||||
mkdir downloads
|
||||
mkdir -p 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 "$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 )
|
||||
name=$(curl -b "$opwd/cookies" -c "$opwd/cookies" -sI https://www.packtpub.com/ebook_download/$id/pdf | grep 'Location' | grep -Eo 'https?://[^?]*' | sed 's@.*/@@' | sed 's@\.pdf@@i' )
|
||||
echo $name
|
||||
out=$(curl -b "$opwd/cookies" -c "$opwd/cookies" -L https://www.packtpub.com/ebook_download/$id/pdf https://www.packtpub.com/ebook_download/$id/epub -o "$name.pdf" -o "$name.epub" 2>&1 )
|
||||
|
||||
ret=$?
|
||||
|
||||
@ -40,3 +40,4 @@ if [ $ret -ne 0 ]; then
|
||||
echo -e "$out"
|
||||
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user