From fa4b73bc51e14ceb1a7acbb25a4e81943ad2d8f5 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Sat, 19 Sep 2020 11:12:00 +0100 Subject: [PATCH] Makes linkhandler handle more It now handles some peertube, more invidious and xkcd --- bin/.bin/linkhandler | 6 +++++- bin/.bin/xkcd | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/.bin/linkhandler b/bin/.bin/linkhandler index ca01768e..77edad12 100755 --- a/bin/.bin/linkhandler +++ b/bin/.bin/linkhandler @@ -9,8 +9,12 @@ url="$1" browser="${BROWSER:-firefox-developer-edition}" case "$url" in - *"//invidio.us/"*) open-youtube "$url"; exit 0 ;; + *"//invidious.*/"*) open-youtube "$url"; exit 0 ;; + *//*.youtube.*/*) open-youtube "$url"; exit 0 ;; + *"//videos.*"*) open-youtube "$url"; exit 0 ;; + *"//xkcd.com/"*) xkcd "$url"; exit 0 ;; *) $browser "$url"; exit 0 ;; + #*) notify-send "$url"; exit ;; esac exit 1 diff --git a/bin/.bin/xkcd b/bin/.bin/xkcd index cef05ca1..1710b2d4 100755 --- a/bin/.bin/xkcd +++ b/bin/.bin/xkcd @@ -7,7 +7,11 @@ elif [[ "$comic" == "random" ]] || [[ "$comic" == "r" ]]; then number=$(shuf -i1-$latest -n1) json=$(curl https://xkcd.com/$number/info.0.json 2> /dev/null) else - json=$(curl https://xkcd.com/$comic/info.0.json 2> /dev/null) + if [[ "$comic" = *"xkcd.com"* ]]; then + json=$(curl $comic/info.0.json 2> /dev/null) + else + json=$(curl https://xkcd.com/$comic/info.0.json 2> /dev/null) + fi fi echo $json | /usr/bin/jq -C echo $json | /usr/bin/jq ".img" | xargs curl -s -o /tmp/xkcd