about summary refs log tree commit diff stats
path: root/sfeed_ass.awk
blob: 8db4e37cd7adb66335baf5cfbe730f4eafba798b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/awk -f
## Converts sfeed(1) files into an Actually Simple Sindication
## (ASS) file.  See https://tilde.town/~dzwdz/ass/ for details.

## THE SPEC

# An .ass file consists of a bunch of lines. Every line represents an item
# (e.g. article).

# Every line consists of:

# an ISO-8601 formatted date with dashes the URI of the item (optionally) the
# title of the item

# Those elements are separated by tabs. Every tab after the URI is treated as
# part of the title. The order of the lines doesn't matter. Additional
# whitespace before the date is NOT permitted.

# Lines can also be empty or start with the # character. Those lines are to be
# ignored by clients. I recommend adding a comment with a link to this page at
# the top, so people won't get confused about what to do with the file.

# It's very highly recommended to name the file "feed.ass". This will make feed
# discovery much easier. If you want to get added to the list of known feeds,
# you MUST name your feed that (the 2 feeds in there are grandfathered in).
BEGIN {
	FS = "\t"
	OFS = "\t"
}

{
	datecmd = "date -u -d '@" ($1 ? $1 : 0) "' +%F"
	datecmd | getline timestamp
	close(datecmd)
	title = $2
	link = $3
	print timestamp, link, title
	if (++line > 25) {
		printf(".") > "/dev/stderr"
		line = 0
	}
}

END {
	print("ok") > "/dev/stderr"
}