]> git.armaanb.net Git - bin.git/commitdiff
rss: add script
authorArmaan Bhojwani <me@armaanb.net>
Tue, 6 Jul 2021 20:32:41 +0000 (16:32 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Tue, 6 Jul 2021 20:32:41 +0000 (16:32 -0400)
man/rss.1.scd [new file with mode: 0644]
rss [new file with mode: 0755]

diff --git a/man/rss.1.scd b/man/rss.1.scd
new file mode 100644 (file)
index 0000000..9ea9f7c
--- /dev/null
@@ -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 <https://unlicense.org/>.
\ No newline at end of file
diff --git a/rss b/rss
new file mode 100755 (executable)
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"/*