diff options
author | Case Duckworth | 2022-07-19 10:05:51 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-19 10:05:51 -0500 |
commit | 106067ae1e826b3d42ca174b7bfdf9b7070cdf82 (patch) | |
tree | 68c01f59a0a1e575d6e2d9499c6bb1b1888f6002 | |
parent | Sanitize fortune output (diff) | |
download | sfeed-106067ae1e826b3d42ca174b7bfdf9b7070cdf82.tar.gz sfeed-106067ae1e826b3d42ca174b7bfdf9b7070cdf82.zip |
Fix reddit handling
Now it links to the external resource if one is present!
-rw-r--r-- | sfeedrc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sfeedrc b/sfeedrc index cee03f6..cda42f2 100644 --- a/sfeedrc +++ b/sfeedrc | |||
@@ -24,7 +24,7 @@ feeds() { | |||
24 | 24 | ||
25 | feeds_planets() { | 25 | feeds_planets() { |
26 | feed "Planet Emacs" "https://planet.emacslife.com/atom.xml" "https://planet.emacslife.com/" "" | 26 | feed "Planet Emacs" "https://planet.emacslife.com/atom.xml" "https://planet.emacslife.com/" "" |
27 | feed "r/emacs" "http://old.reddit.com/r/emacs.rss" "http://old.reddit.com/r/emacs" "" | 27 | feed "r/emacs" "https://i.reddit.com/r/emacs.rss" "https://i.reddit.com/r/emacs" "" |
28 | feed "Planet Lisp" "https://planet.lisp.org/rss20.xml" "https://planet.lisp.org/" "" | 28 | feed "Planet Lisp" "https://planet.lisp.org/rss20.xml" "https://planet.lisp.org/" "" |
29 | feed "Planet Scheme" "https://planet.scheme.org/atom.xml" "https://planet.scheme.org/" "" | 29 | feed "Planet Scheme" "https://planet.scheme.org/atom.xml" "https://planet.scheme.org/" "" |
30 | } | 30 | } |
@@ -177,10 +177,19 @@ print | |||
177 | *NPR*) | 177 | *NPR*) |
178 | sed 's@www\.npr\.org@text.npr.org@' | 178 | sed 's@www\.npr\.org@text.npr.org@' |
179 | ;; | 179 | ;; |
180 | r_* | r/*) # reddit (not sure when / => _) | 180 | r_* | r/*) |
181 | reddit_alt_url="i.reddit.com" # teddit is slow :( | 181 | # Reddit doesn't include a link as its item IDs, but instead |
182 | sed -e "s@old\.reddit\.com@${reddit_alt_url}@" \ | 182 | # something of the form `t3_xxxxx', where xxxxx can be glommed |
183 | -e "s@reddit\.com@${reddit_alt_url}@" | 183 | # into a URL to get to the comments. |
184 | awk -v SUBREDDIT="$1" -v ALT=i.reddit.com \ | ||
185 | 'BEGIN {FS="\t";OFS="\t"} | ||
186 | { $6 = $3 #ALT "/" SUBREDDIT "/" substr($6, 4) | ||
187 | } | ||
188 | { | ||
189 | if (match($4,/<a href="([^"]*)">\[link\]<\/a>/,ln)) $3 = ln[1] | ||
190 | } | ||
191 | { gsub(/www\.reddit\.com/, ALT, $0) } | ||
192 | { print }' | ||
184 | ;; | 193 | ;; |
185 | 'Saturday Morning Breakfast Cereal') | 194 | 'Saturday Morning Breakfast Cereal') |
186 | sed 's@Saturday Morning Breakfast Cereal - @@' | 195 | sed 's@Saturday Morning Breakfast Cereal - @@' |