Last active
January 19, 2016 03:58
-
-
Save denpatin/a2a80071eb96755fc07d to your computer and use it in GitHub Desktop.
Script for downloading free books from Springer
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
#!/bin/bash | |
# | |
# Usage: | |
# $ springer.sh | |
# will save all books | |
# | |
# $ springer.sh word | |
# will save all books whose titles or authors match "word" | |
# Link with books and links | |
springer="https://gist.githubusercontent.com/bishboria/8326b17bbd652f34566a/raw/0594f99c580c3befb924f3d36ab187c2da8f441b/springer-free-maths-books.md" | |
# Processing the argument | |
param="" | |
if [ ! -z "$1" ] | |
then | |
export param="$1" | |
fi | |
while read -r book | |
do | |
# Parsing markdown | |
link=$(echo "$book" | awk -F'[][()]' '{print $4}') | |
# Contains title and author | |
naming=$(echo "$book" | awk -F'[][()]' '{print $2}') | |
author=$(echo "$naming" | awk -F, '{print $NF}' | sed 's/^ //g') | |
title=$(echo "$naming" | sed "s/$author$//" | rev | cut -c 3- | rev | sed 's/[:*"]//g') | |
file="$title ($author).pdf" | |
# If a file exists (that is, either the newest edition is already downloaded, or the script | |
# is being run once again), then skip the book cuz we need neither older version nor duplicate | |
if [ -f "$file" ]; then continue; fi | |
# Downloading the file with a new name | |
wget -O "$file" "$link" -q --show-progress -o /dev/null | |
# Get only lines that contain links, and output them in a reversed order | |
done < <(curl "$springer" | sed '/^[^[]*$/d' | sed '1!G;h;$!d' | grep -i "$param") |
@isaacmao
This option works for wget starting from version 1.16. Just update it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why it reports such error?
wget: unrecognized option '--show-progress'