Modified code to download newly named files

This commit is contained in:
Christian Wolf 2016-01-27 15:23:36 +01:00
parent e2c4cb11ea
commit fa607357b5
2 changed files with 7 additions and 5 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
cookies cookies
downloads downloads
*~

9
run.sh
View File

@ -14,15 +14,15 @@ if [ $# -eq 1 ]; then
mkdir -p "$1" mkdir -p "$1"
cd "$1" cd "$1"
else else
mkdir downloads mkdir -p downloads
cd downloads cd downloads
fi fi
echo 'Downloading books' echo 'Downloading books'
id=$(echo $url | grep -o '/[0-9/]*/' | grep -o '[0-9]*') 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 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' )
#curl -b cookies -c cookies -J -O https://www.packtpub.com/ebook_download/$id/epub echo $name
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 ) 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=$? ret=$?
@ -40,3 +40,4 @@ if [ $ret -ne 0 ]; then
echo -e "$out" echo -e "$out"
fi fi