From 0608408fbc36dae25ab5cc114fb51b622ecc5937 Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 1 Feb 2022 01:24:14 +0000 Subject: wikipedia-handler --- contrib/wikipedia-handler | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 contrib/wikipedia-handler (limited to 'contrib/wikipedia-handler') diff --git a/contrib/wikipedia-handler b/contrib/wikipedia-handler new file mode 100755 index 0000000..724bda5 --- /dev/null +++ b/contrib/wikipedia-handler @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +xmessage "loading page for: $1" +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}")")" +curl -H "If-Modified-Since: ${last_modified}" -L -s -g "https://en.wikipedia.org/api/rest_v1/page/pdf/${page}" -o "${cache_file}" +fileuri=file://"${cache_file}" +uristart "${fileuri}" -- cgit v1.2.3