plumb.sh: fix stray \ grep warning on Linux, use nitter for Twitter - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit b2bb1c9e8b3c98210611b9990ab5fdc362a6a4fb
(DIR) parent ae6331b18d88af91ce83c7d06e1cd07c9ac276e6
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 11 Jul 2023 14:21:15 +0200
plumb.sh: fix stray \ grep warning on Linux, use nitter for Twitter
Diffstat:
M config/scripts/plumb.sh | 33 +++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
---
(DIR) diff --git a/config/scripts/plumb.sh b/config/scripts/plumb.sh
@@ -123,7 +123,7 @@ if match "$text" '^(gopher|gophers)://'; then
elif match "$text" '\.(png|jpg|jpeg|webp|bmp)$' 'i'; then
image "$out"
fi
-elif match "$text" '^(lbry):\/\/'; then
+elif match "$text" '^(lbry)://'; then
text=$("$HOME/.config/scripts/plumb/lbry.sh" "$text")
movie "$text"
elif match "$text" '^(http|https)://([a-zA-Z0-9]*\.)?wikipedia\.org/'; then
@@ -141,22 +141,22 @@ elif match "$text" '\.(gifv)$' 'i'; then
# replace gifv with mp4
text=$(printf '%s' "$text" | sed 's@gifv$@mp4@')
movie "$text"
-elif match "$text" 'https:\/\/docs\.google\.com\/document\/d' 'i'; then
+elif match "$text" 'https://docs\.google\.com/document/d' 'i'; then
# google docs: export document to PDF.
- id=$(printf '%s' "$text" | sed -nE 's@.*https://docs\.google\.com/document/d/([^\/]*).*@\1@p')
+ id=$(printf '%s' "$text" | sed -nE 's@.*https://docs\.google\.com/document/d/([^/]*).*@\1@p')
if test -n "$id"; then
# download, view in pdf viewer, then delete.
text="https://docs.google.com/document/d/$id/export?format=pdf"
tempview pdf "$text"
fi
-elif match "$text" '^(http|https):\/\/imgur\.com\/a/'; then
+elif match "$text" '^(http|https)://imgur\.com/a/'; then
# album viewer
albumid="${text##*/}"
tmp=$(mktemp)
"$HOME/.config/scripts/plumb/imgur_album.sh" "$albumid" > "$tmp"
st -e less "$tmp"
rm -f "$tmp"
-elif match "$text" '^(http|https):\/\/imgur\.com\/'; then
+elif match "$text" '^(http|https)://imgur\.com/'; then
imgid="$(printf '%s' "$text" | sed -E 's@^(http|https)://imgur.com/@@')"
if test x"$imgid" != x""; then
text="https://i.imgur.com/$imgid.jpg"
@@ -164,10 +164,10 @@ elif match "$text" '^(http|https):\/\/imgur\.com\/'; then
else
www "$text"
fi
-elif match "$text" ':\/\/i\.imgur\.com\/'; then
+elif match "$text" '://i\.imgur\.com/'; then
# download, view in image viewer, then delete.
tempview image "$text"
-elif match "$text" '^(http|https):\/\/explosm\.net\/comics\/[0-9]+\/'; then
+elif match "$text" '^(http|https)://explosm\.net/comics/[0-9]+/'; then
# grab direct comic image url.
# TODO: make this some more generic og:image / og:video function? maybe using "xml2tsv".
# see: https://ogp.me/
@@ -187,10 +187,21 @@ elif match "$text" '^(http|https)://(sprunge\.us|ix\.io|0x0\.st|termbin\.com)/';
elif match "$text" '^(http|https)://.*(\.youtube\.|youtu\.be)'; then
movie "$text"
elif match "$text" '^(http|https)://.*(\.?twitter\.com)/'; then
- tmp=$(mktemp)
- "$HOME/.config/scripts/plumb/twitter_status.sh" "$text" > "$tmp"
- st -e less "$tmp"
- rm -f "$tmp"
+ url="${text}"
+ url="${url#http://}"
+ url="${url#https://}"
+ url="${url#www.}"
+ url="${url#twitter.com}"
+ url="${url#/}"
+ # replace with nitter instance.
+ url="https://nitter.net/${url}"
+ www "$url"
+
+ # old twitter status script
+# tmp=$(mktemp)
+# "$HOME/.config/scripts/plumb/twitter_status.sh" "$text" > "$tmp"
+# st -e less "$tmp"
+# rm -f "$tmp"
elif match "$text" '^(http|https)://([^a-z]*\.)?twitch\.tv'; then
movie "$text"
elif match "$text" '^(http|https)://'; then