From a8bd0bb1b73a2ca13eda633726b85f644b1edf4b Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Tue, 6 Jul 2021 16:32:41 -0400 Subject: [PATCH] rss: add script --- man/rss.1.scd | 15 +++++++++++++++ rss | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 man/rss.1.scd create mode 100755 rss diff --git a/man/rss.1.scd b/man/rss.1.scd new file mode 100644 index 0000000..9ea9f7c --- /dev/null +++ b/man/rss.1.scd @@ -0,0 +1,15 @@ +rss(1) + +# NAME +rss - fetch rss feeds and launch sfeed_curses + +# SYNOPSIS +rss [path to feeds] + +# DESCRIPTION +Downloads feeds from the first argument (defaults to ~/org/feeds), and opens +them in sfeed_curses. Depends on sfeed_curses and libxml2. + +# COPYRIGHT +This is free and unencumbered software released into the public domain. For more +information, please refer to . \ No newline at end of file diff --git a/rss b/rss new file mode 100755 index 0000000..cfd93e6 --- /dev/null +++ b/rss @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +file=${2:-$HOME/org/feeds} +total=$(wc -l "$file" | cut -d " " -f 1) +cachedir=${XDG_CACHE_HOME:-$HOME/.cache/}/sfeed + +mkdir -p "$cachedir" + +i=1 +while read -r feed; do + printf "Downloading %s\n%s/%s\r" "$feed" "$i" "$total" + curl -s "$feed" | xmllint --format - > /tmp/sfeed + + title="$(grep -m 1 title /tmp/sfeed | xmllint --xpath "string(//title)" -)" + domain=$(echo "$feed" | cut -d/ -f 3) + fname=$(echo "${title:-$domain}" | sed 's|/|!|g' | head -c 25) + sfeed < /tmp/sfeed > "$cachedir/$fname" + + i=$((i+1)) +done < "$file" + +rm /tmp/sfeed + +sfeed_curses "$cachedir"/* -- 2.39.2