summaryrefslogtreecommitdiff
path: root/contrib/wikipedia-search-handler
diff options
context:
space:
mode:
authorepoch <epoch@enzo.thebackupbox.net>2022-02-01 03:21:34 +0000
committerepoch <epoch@enzo.thebackupbox.net>2022-02-01 03:21:34 +0000
commitda5080c53ce8e9e520187e19eeb907c46607b4f0 (patch)
tree415adf4e588615f7989b55a91fa512453b07bade /contrib/wikipedia-search-handler
parent0608408fbc36dae25ab5cc114fb51b622ecc5937 (diff)
downloaduritools-da5080c53ce8e9e520187e19eeb907c46607b4f0.tar.gz
uritools-da5080c53ce8e9e520187e19eeb907c46607b4f0.zip
wikipedia search handler added and normal handler updated
Diffstat (limited to 'contrib/wikipedia-search-handler')
-rwxr-xr-xcontrib/wikipedia-search-handler17
1 files changed, 17 insertions, 0 deletions
diff --git a/contrib/wikipedia-search-handler b/contrib/wikipedia-search-handler
new file mode 100755
index 0000000..72f051f
--- /dev/null
+++ b/contrib/wikipedia-search-handler
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+uri="$1"
+shortened="$(unshorten.sh "${uri}")"
+if [ "${shortened}" ];then
+ uri="${shortened}"
+fi
+shortened="$(unshorten.sh "${uri}")"
+if [ "${shortened}" ];then
+ uri="${shortened}"
+ uristart "$uri"
+else
+ curl -g "$uri" | grep '^<i>The page "<a href="/w/index' | sed 's|<i>\([^<]\)</i>||g' | tr '<' '\n' \
+ | grep ^a \
+ | cut '-d"' -f2 \
+ | sed 's|^/|https://en.wikipedia.org/|g' \
+ | text_uri-list
+fi