blob: c9aaae6de4d82640b788c2bd52770ac920b738f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#!/usr/bin/env bash
page="$(uriescape "$1")"
cache_file=~/.cache/wikipedia/"${page}.pdf"
mkdir -p ~/.cache/wikipedia
## follow redirects (-L), silent (-s), and no globbing (-g), you can guess what -H does.
last_modified="$(rfc7231date "$(stat -c '%Y' "${cache_file}")")"
if [ "$last_modified" ];then
curl -H "If-Modified-Since: ${last_modified}" -L -s -g "https://en.wikipedia.org/api/rest_v1/page/pdf/${page}" -o "${cache_file}"
else
curl -L -s -g "https://en.wikipedia.org/api/rest_v1/page/pdf/${page}" -o "${cache_file}"
fi
fileuri=file://"${cache_file}"
uristart "${fileuri}"
|