| sfeed_update/sfeedrc: add url as parameter to the filter() and order() function - sfeed - RSS and Atom parser |
| git clone git://git.codemadness.org/sfeed |
| Log |
| Files |
| Refs |
| README |
| LICENSE |
| --- |
| commit 96d7afc7d7511f05ba07c5acbb5bbfb2847bc126 |
| parent 21790adad1672689225efe38b6a59494181d323b |
| Author: Hiltjo Posthuma |
| Date: Fri, 9 Jun 2023 14:40:40 +0200
sfeed_update/sfeedrc: add url as parameter to the filter() and order() function
This might make it easier to set filters or ordering by pattern matching on a
group of feeds by the feed URL. For example youtube or reddit feeds.
Another way which was already possible is prefixing names with for example:
"reddit somename" or "yt somename".
Diffstat:
M README | 2 +-
M sfeed_update | 8 ++++----
M sfeedrc.5 | 10 +++++++---
3 files changed, 12 insertions(+), 8 deletions(-)
--- |
| diff --git a/README b/README |
| @@ -336,7 +336,7 @@ filtering items per feed. It can be used to shorten URLs, filter away
advertisements, strip tracking parameters and more.
# filter fields.
- # filter(name)
+ # filter(name, url)
filter() {
case "$1" in
"tweakers") |
| diff --git a/sfeed_update b/sfeed_update |
| @@ -71,7 +71,7 @@ parse() {
}
# filter fields.
-# filter(name)
+# filter(name, url)
filter() {
cat
}
@@ -83,7 +83,7 @@ merge() {
}
# order by timestamp (descending).
-# order(name)
+# order(name, url)
order() {
sort -t ' ' -k1rn,1
}
@@ -124,7 +124,7 @@ _feed() {
fi
rm -f "${tmpfeedfile}.utf8"
- if ! filter "${name}" < "${tmpfeedfile}.tsv" > "${tmpfeedfile}.filter"; then
+ if ! filter "${name}" "${feedurl}" < "${tmpfeedfile}.tsv" > "${tmpfeedfile}.filter"; then
log_error "${name}" "FAIL (FILTER)"
return 1
fi
@@ -142,7 +142,7 @@ _feed() {
fi
rm -f "${tmpfeedfile}.filter"
- if ! order "${name}" < "${tmpfeedfile}.merge" > "${tmpfeedfile}.order"; then
+ if ! order "${name}" "${feedurl}" < "${tmpfeedfile}.merge" > "${tmpfeedfile}.order"; then
log_error "${name}" "FAIL (ORDER)"
return 1
fi |
| diff --git a/sfeedrc.5 b/sfeedrc.5 |
| @@ -1,4 +1,4 @@
-.Dd January 18, 2023
+.Dd June 9, 2023
.Dt SFEEDRC 5
.Os
.Sh NAME
@@ -101,13 +101,15 @@ URL of the feed.
Base URL of the feed links.
This argument allows to fix relative item links.
.El
-.It Fn filter "name"
+.It Fn filter "name" "url"
Filter
.Xr sfeed 5
data from stdin and write it to stdout, its arguments are:
.Bl -tag -width Ds
.It Fa name
Feed name.
+.It Fa url
+URL of the feed.
.El
.It Fn merge "name" "oldfile" "newfile"
Merge
@@ -121,13 +123,15 @@ Old file.
.It Fa newfile
New file.
.El
-.It Fn order "name"
+.It Fn order "name" "url"
Sort
.Xr sfeed 5
data from stdin and write it to stdout, its arguments are:
.Bl -tag -width Ds
.It Fa name
Feed name.
+.It Fa url
+URL of the feed.
.El
.El
.Sh EXAMPLES |