]> git.armaanb.net Git - bin.git/blobdiff - rss
rss: add script
[bin.git] / rss
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"/*