sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

sfeedrc.5 (4649B)


      1.Dd December 26, 2023
      2.Dt SFEEDRC 5
      3.Os
      4.Sh NAME
      5.Nm sfeedrc
      6.Nd sfeed_update(1) configuration file
      7.Sh DESCRIPTION
      8.Nm
      9is the configuration file for
     10.Xr sfeed_update 1 .
     11.Sh VARIABLES
     12.Bl -tag -width Ds
     13.It Va sfeedpath
     14can be set for the directory to store the TAB-separated feed files.
     15The default is
     16.Pa $HOME/.sfeed/feeds .
     17.It Va maxjobs
     18can be used to change the amount of concurrent
     19.Fn feed
     20jobs.
     21The default is 16.
     22.El
     23.Sh FUNCTIONS
     24.Bl -tag -width Ds
     25.It Fn feeds
     26This function is the required "main" entry-point function called from
     27.Xr sfeed_update 1 .
     28.It Fn feed "name" "feedurl" "basesiteurl" "encoding"
     29Inside the
     30.Fn feeds
     31function feeds can be defined by calling the
     32.Fn feed
     33function, its arguments are:
     34.Bl -tag -width Ds
     35.It Fa name
     36Name of the feed, this is also used as the filename for the TAB-separated
     37feed file.
     38The feed name cannot contain the '/' character because it is a path separator,
     39they will be replaced with '_'.
     40Each
     41.Fa name
     42should be unique.
     43.It Fa feedurl
     44URL to fetch the RSS/Atom data from, usually a HTTP or HTTPS URL.
     45.It Op Fa basesiteurl
     46Base URL of the feed links.
     47This argument allows to fix relative item links.
     48.Pp
     49According to the RSS and Atom specification feeds should always have absolute
     50URLs, however this is not always the case in practise.
     51.It Op Fa encoding
     52Feeds are decoded from this name to UTF-8, the name should be a usable
     53character-set for the
     54.Xr iconv 1
     55tool.
     56.El
     57.El
     58.Sh OVERRIDE FUNCTIONS
     59Because
     60.Xr sfeed_update 1
     61is a shellscript each function can be overridden to change its behaviour,
     62notable functions are:
     63.Bl -tag -width Ds
     64.It Fn fetch "name" "url" "feedfile"
     65Fetch feed from URL and write the data to stdout, its arguments are:
     66.Bl -tag -width Ds
     67.It Fa name
     68Specified name in configuration file (useful for logging).
     69.It Fa url
     70URL to fetch.
     71.It Fa feedfile
     72Used feedfile (useful for comparing modification times).
     73.El
     74.Pp
     75By default the tool
     76.Xr curl 1
     77is used.
     78.It Fn convertencoding "name" "from" "to"
     79Convert data from stdin from one text-encoding to another and write it to
     80stdout,
     81its arguments are:
     82.Bl -tag -width Ds
     83.It Fa name
     84Feed name.
     85.It Fa from
     86From text-encoding.
     87.It Fa to
     88To text-encoding.
     89.El
     90.Pp
     91By default the tool
     92.Xr iconv 1
     93is used.
     94.It Fn parse "name" "feedurl" "basesiteurl"
     95Read RSS/Atom XML data from stdin, convert and write it as
     96.Xr sfeed 5
     97data to stdout.
     98.Bl -tag -width Ds
     99.It Fa name
    100Name of the feed.
    101.It Fa feedurl
    102URL of the feed.
    103.It Fa basesiteurl
    104Base URL of the feed links.
    105This argument allows to fix relative item links.
    106.El
    107.It Fn filter "name" "url"
    108Filter
    109.Xr sfeed 5
    110data from stdin and write it to stdout, its arguments are:
    111.Bl -tag -width Ds
    112.It Fa name
    113Feed name.
    114.It Fa url
    115URL of the feed.
    116.El
    117.It Fn merge "name" "oldfile" "newfile"
    118Merge
    119.Xr sfeed 5
    120data of oldfile with newfile and write it to stdout, its arguments are:
    121.Bl -tag -width Ds
    122.It Fa name
    123Feed name.
    124.It Fa oldfile
    125Old file.
    126.It Fa newfile
    127New file.
    128.El
    129.It Fn order "name" "url"
    130Sort
    131.Xr sfeed 5
    132data from stdin and write it to stdout, its arguments are:
    133.Bl -tag -width Ds
    134.It Fa name
    135Feed name.
    136.It Fa url
    137URL of the feed.
    138.El
    139.El
    140.Sh EXAMPLES
    141An example configuration file is included named sfeedrc.example and also
    142shown below:
    143.Bd -literal
    144#sfeedpath="$HOME/.sfeed/feeds"
    145
    146# list of feeds to fetch:
    147feeds() {
    148	# feed <name> <feedurl> [basesiteurl] [encoding]
    149	feed "codemadness" "https://www.codemadness.org/atom_content.xml"
    150	feed "explosm" "http://feeds.feedburner.com/Explosm"
    151	feed "golang github releases" "https://github.com/golang/go/releases.atom"
    152	feed "linux kernel" "https://www.kernel.org/feeds/kdist.xml" "https://www.kernel.org"
    153	feed "reddit openbsd" "https://old.reddit.com/r/openbsd/.rss"
    154	feed "slashdot" "http://rss.slashdot.org/Slashdot/slashdot" "http://slashdot.org"
    155	feed "tweakers" "http://feeds.feedburner.com/tweakers/mixed" "http://tweakers.net" "iso-8859-1"
    156	# get youtube Atom feed: curl -s -L 'https://www.youtube.com/user/gocoding/videos' | sfeed_web | cut -f 1
    157	feed "youtube golang" "https://www.youtube.com/feeds/videos.xml?channel_id=UCO3LEtymiLrgvpb59cNsb8A"
    158	feed "xkcd" "https://xkcd.com/atom.xml" "https://xkcd.com"
    159}
    160.Ed
    161.Pp
    162To change the default
    163.Xr curl 1
    164options for fetching the data, the
    165.Fn fetch
    166function can be overridden and added at the top of the
    167.Nm
    168file:
    169.Bd -literal
    170# fetch(name, url, feedfile)
    171fetch() {
    172	# allow for 1 redirect, set User-Agent, timeout is 15 seconds.
    173	curl -L --max-redirs 1 -H "User-Agent: 007" -f -s -m 15 \e
    174		"$2" 2>/dev/null
    175}
    176.Ed
    177.Sh SEE ALSO
    178.Xr curl 1 ,
    179.Xr iconv 1 ,
    180.Xr sfeed_update 1 ,
    181.Xr sh 1
    182.Sh AUTHORS
    183.An Hiltjo Posthuma Aq Mt hiltjo@codemadness.org