diff options
author | Case Duckworth | 2022-08-10 23:03:37 -0500 |
---|---|---|
committer | Case Duckworth | 2022-08-10 23:03:47 -0500 |
commit | 14295db5998bf04d8debc112322f33c66af458d5 (patch) | |
tree | a95d012af14ee9df7367c0c3032b87c3ef8e16f4 | |
parent | Add ass (diff) | |
download | sfeed-14295db5998bf04d8debc112322f33c66af458d5.tar.gz sfeed-14295db5998bf04d8debc112322f33c66af458d5.zip |
Add sfeed_ass.awk
-rwxr-xr-x | sfeed_ass.awk | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sfeed_ass.awk b/sfeed_ass.awk new file mode 100755 index 0000000..8db4e37 --- /dev/null +++ b/sfeed_ass.awk | |||
@@ -0,0 +1,47 @@ | |||
1 | #!/usr/bin/awk -f | ||
2 | ## Converts sfeed(1) files into an Actually Simple Sindication | ||
3 | ## (ASS) file. See https://tilde.town/~dzwdz/ass/ for details. | ||
4 | |||
5 | ## THE SPEC | ||
6 | |||
7 | # An .ass file consists of a bunch of lines. Every line represents an item | ||
8 | # (e.g. article). | ||
9 | |||
10 | # Every line consists of: | ||
11 | |||
12 | # an ISO-8601 formatted date with dashes the URI of the item (optionally) the | ||
13 | # title of the item | ||
14 | |||
15 | # Those elements are separated by tabs. Every tab after the URI is treated as | ||
16 | # part of the title. The order of the lines doesn't matter. Additional | ||
17 | # whitespace before the date is NOT permitted. | ||
18 | |||
19 | # Lines can also be empty or start with the # character. Those lines are to be | ||
20 | # ignored by clients. I recommend adding a comment with a link to this page at | ||
21 | # the top, so people won't get confused about what to do with the file. | ||
22 | |||
23 | # It's very highly recommended to name the file "feed.ass". This will make feed | ||
24 | # discovery much easier. If you want to get added to the list of known feeds, | ||
25 | # you MUST name your feed that (the 2 feeds in there are grandfathered in). | ||
26 | BEGIN { | ||
27 | FS = "\t" | ||
28 | OFS = "\t" | ||
29 | } | ||
30 | |||
31 | { | ||
32 | datecmd = "date -u -d '@" ($1 ? $1 : 0) "' +%F" | ||
33 | datecmd | getline timestamp | ||
34 | close(datecmd) | ||
35 | title = $2 | ||
36 | link = $3 | ||
37 | print timestamp, link, title | ||
38 | if (++line > 25) { | ||
39 | printf(".") > "/dev/stderr" | ||
40 | line = 0 | ||
41 | } | ||
42 | } | ||
43 | |||
44 | END { | ||
45 | print("ok") > "/dev/stderr" | ||
46 | } | ||
47 | |||