-
-
Save youkoucoding/a52b0bceb9886c0f672e1c0fa011e4b3 to your computer and use it in GitHub Desktop.
Download all the books from a talebook website.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Download metadata, modify these as your needs. | |
download_directory="/Volumes/Download/EPUB" | |
index_file="/Users/Yufan/Downloads/startIndex" | |
calibre_site="http://soulseeker.myds.me:25788" | |
cookie_content='user_id="2|1:0|10:1648963149|7:user_id|4:MjE=|22392d10a223babcf803fdb017893b8dbd6c2a1d2f539da2d4739d38cb682977"; lt="2|1:0|10:1648963149|2:lt|16:MTY0ODk2MzE0OQ==|81b175537a41b2a2c1cefaa9ac299b3c60b6ebf065b8a2fd0a5ba67e07c063a1"; admin_id="2|1:0|10:1648963139|8:admin_id|0:|181e17ec95521a99c887d8bc63ce60b4c45a1ec6e86b527850230991fe858cb5"' | |
minimal_size=10240 | |
## Don't modify the scripts below. | |
function query_start_index() { | |
if [ ! -f "$index_file" ]; then | |
touch $index_file | |
echo 1 > $index_file | |
fi | |
echo $(cat $index_file) | |
} | |
startIndex=$(query_start_index) | |
echo "Start to download from $startIndex" | |
for((i=$startIndex; i<=22451; i++)); | |
do | |
file_path=$download_directory/$i.epub | |
file_url=$calibre_site/api/book/$i.EPUB | |
echo "Start downloading $file_url" | |
curl --cookie "$cookie_content" "$file_url" --output "$file_path" | |
echo "Finish download $file_url" | |
file_size=`ls -l $file_path | awk '{print $5}'` | |
if [ $file_size -lt $minimal_size ]; then | |
echo "$file_path is a blank file, remove it." | |
rm -rf $file_path | |
fi | |
echo $i > $index_file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment