# sfeed show mastodon toot title
2024-02-20T14:03:20Z
I use sfeed to read feeds, and I love it.
=>
https://codemadness.org/sfeed.html
I also prefer to follow people on mastodon with the associated rss feed, I mean
https://instance.tld/@username.rss.
However, this rss feed don't have a title, resulting of the publication date displayed in sfeed_curses.
Even if I can read the toot when pressing enter, I'd like to see a preview of the toot.
sfeed is so good that you can write you own filter() function.
So now, in my sfeedrc, I have:
```
filter() {
case "$1" in
masto*:*)
# don't insert date in title, just first line
awk -F '\t' 'BEGIN { OFS = "\t"; }
{
# turn description into title
$2 = gensub("<[^>]+>", " ", "G", $4)
print $0
}
'
;;
```
It isn't perfect, but give a nice preview:
```
2024-02-19 11:12 I forgot about audacity's fork Tenacity it's still alive! https:// codeber…
2024-02-18 17:04 Interesting project, but a bit weird it's a tool to create interactive documents, i…
2024-02-14 16:39 TIL ecryptfs doesn't support very long file names long as in 148 characters "only"
2024-02-12 19:24 As a former ZNC user, is there an advantage at switching to soju? I don't have any ZNC…
2024-02-11 16:48 If you want to experience # Gentoo Linux for the first time, or if you are bored wit…
2024-02-08 23:50 # OpenBSD may introduces Word into the base system https:// marc.info/?l=openbsd…
```
Of course, I have to name mastodon feeds with "masto<someting>:otherthing" like this:
```
feed 'masto:
[email protected]' '
https://fosstodon.org/@drewdevault.rss'
feed 'masto:
[email protected]' '
https://pouet.chapril.org/@fredg.rss'
feed 'masto:
[email protected]' '
https://mamot.fr/@ploum.rss'
feed 'masto:
[email protected]' '
https://im-in.space/@noroanka.rss'
feed 'masto:
[email protected]' '
https://bsd.network/@solene.rss' "" "iso-8859-1"
feed 'mastotag:solarpunk' '
https://im-in.space/tags/solarpunk.rss'
feed 'mastotag:openbsd' '
https://im-in.space/tags/openbsd.rss'
```
You you're interesed, here is the full filter() I use now:
```
filter() {
case "$1" in
masto*:*)
# don't insert date in title, just first line
awk -F '\t' 'BEGIN { OFS = "\t"; }
{
# turn description into title
$2 = gensub("<[^>]+>", "", "G", $4)
print $0
}
'
;;
"xkcd.com")
# do not turn html with w3m/lynx -dump to get img url
awk -F '\t' 'BEGIN { OFS = "\t"; }
{
$5 = "plain";
# extract img url
match($4, "src=\"(.+)");
imglink = substr($4, RSTART,RLENGTH);
split(imglink , a, "\"");
imglink = a[2];
# same with alt
match($4, "alt=\"(.+)");
alt = substr($4, RSTART,RLENGTH);
split(alt , a, "\"");
alt = a[2]
# append img link at the end
$4 = sprintf("%s \\n=> %s", alt, imglink);
print $0
# download the img
#cmd = sprintf("cd /home/prx/lessernet/box/; curl -O -s -L -H 'User-Agent:' '%s'", imglink)
#system(cmd)
}
'
;;
*)
cat
;;
esac | \
# replace privacy invasive services with alternatives
# see
https://farside.link/
sed 's@www\.youtube\.com/@invidious.fdn.fr/@g' | \
sed 's@youtu\.be/@invidious.fdn.fr/@g' | \
sed 's@.*twitter\.com/@
https://nitter.net/@g' | \
sed 's@.*reddit\.com/@
https://i.opnxng.com/@g' | \
sed 's@.*medium\.com/@
https://scribe.rip/@g' | \
awk -F '\t' 'BEGIN { OFS = "\t"; }
function filterlink(s) {
# protocol must start with http, https or gopher.
if (match(s, /^(http|https|gopher):\/\//) == 0) {
return "";
}
# shorten feedburner links.
if (match(s, /^(http|https):\/\/[^\/]+\/~r\/.*\/~3\/[^\/]+\//)) {
s = substr($3, RSTART, RLENGTH);
}
# strip tracking parameters
# urchin, facebook, piwik, webtrekk and generic.
gsub(/\?(ad|campaign|fbclid|pk|tm|utm|wt)_([^&]+)/, "?", s);
gsub(/&(ad|campaign|fbclid|pk|tm|utm|wt)_([^&]+)/, "", s);
gsub(/\?&/, "?", s);
gsub(/[\?&]+$/, "", s);
return s
}
{
$3 = filterlink($3); # link
$8 = filterlink($8); # enclosure
# try to remove tracking pixels: <img/> tags with 1px width or height.
gsub("<img[^>]*(width|height)[[:space:]]*=[[:space:]]*[\"'"'"' ]?1[\"'"'"' ]?[^0-9>]+[^>]*>", "", $4);
print $0;
}'
}
```
---
Comments?
Send it by mail (anonymous, add a signature if you want):
=> mailto:
[email protected]?subject=sfeed-mastodon-title
Diff list instructions:
=>
https://si3t.ch/log/_commentaires_.txt