mastadon-filter.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
mastadon-filter.sh (650B)
---
1 #!/bin/sh
2 # Mastadon sfeed filter to fix-up the crappy RSS feed.
3
4 # ugly hack: change media:content to use as enclosure (typically some image).
5 sed -E \
6 -e 's@<media:content @<enclosure @g' \
7 -e 's@</media:content@</enclosure>@g' | \
8 sfeed | \
9 LC_ALL=C awk '
10 BEGIN {
11 FS = OFS = "\t";
12 }
13 # title is empty, use description as title.
14 $2 == "" {
15 $2 = $4;
16 }
17 function filtertitle(s) {
18 gsub("̵[67];", "'"'"'", s);
19 gsub("'", "'"'"'", s)
20 gsub("<[/]?em>", "_", s);
21 gsub("<[/]?b>", "*", s);
22 # strip other tags.
23 gsub("</[a-z]*>", "", s);
24 gsub("<[a-z][^>]*>", "", s);
25 return s;
26 }
27 {
28 # strip ugly HTML etc.
29 $2 = filtertitle($2);
30
31 print $0;
32 }'