voidrice/.local/bin/rssadd

19 lines
554 B
Text
Raw Normal View History

#!/bin/sh
2021-04-07 11:46:50 -04:00
if echo "$1" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ; then
url="$1"
else
url="$(grep -Eom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$1" |
2021-04-07 11:46:50 -04:00
grep -o "https?://[^\" ]")"
2021-04-07 11:46:50 -04:00
echo "$url" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ||
notify-send "That doesn't look like a full URL." && exit 1
fi
2020-04-08 19:10:00 -04:00
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then
2019-03-20 14:45:08 -04:00
notify-send "You already have this RSS feed."
2019-03-12 21:20:17 -04:00
else
echo "$url" >> "$RSSFILE" && notify-send "RSS feed added."
2019-03-12 21:20:17 -04:00
fi