From 106067ae1e826b3d42ca174b7bfdf9b7070cdf82 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 19 Jul 2022 10:05:51 -0500 Subject: Fix reddit handling Now it links to the external resource if one is present! --- sfeedrc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sfeedrc b/sfeedrc index cee03f6..cda42f2 100644 --- a/sfeedrc +++ b/sfeedrc @@ -24,7 +24,7 @@ feeds() { feeds_planets() { feed "Planet Emacs" "https://planet.emacslife.com/atom.xml" "https://planet.emacslife.com/" "" - feed "r/emacs" "http://old.reddit.com/r/emacs.rss" "http://old.reddit.com/r/emacs" "" + feed "r/emacs" "https://i.reddit.com/r/emacs.rss" "https://i.reddit.com/r/emacs" "" feed "Planet Lisp" "https://planet.lisp.org/rss20.xml" "https://planet.lisp.org/" "" feed "Planet Scheme" "https://planet.scheme.org/atom.xml" "https://planet.scheme.org/" "" } @@ -177,10 +177,19 @@ print *NPR*) sed 's@www\.npr\.org@text.npr.org@' ;; - r_* | r/*) # reddit (not sure when / => _) - reddit_alt_url="i.reddit.com" # teddit is slow :( - sed -e "s@old\.reddit\.com@${reddit_alt_url}@" \ - -e "s@reddit\.com@${reddit_alt_url}@" + r_* | r/*) + # Reddit doesn't include a link as its item IDs, but instead + # something of the form `t3_xxxxx', where xxxxx can be glommed + # into a URL to get to the comments. + awk -v SUBREDDIT="$1" -v ALT=i.reddit.com \ + 'BEGIN {FS="\t";OFS="\t"} +{ $6 = $3 #ALT "/" SUBREDDIT "/" substr($6, 4) +} +{ +if (match($4,/\[link\]<\/a>/,ln)) $3 = ln[1] +} +{ gsub(/www\.reddit\.com/, ALT, $0) } +{ print }' ;; 'Saturday Morning Breakfast Cereal') sed 's@Saturday Morning Breakfast Cereal - @@' -- cgit 1.4.1-21-gabe81