From 8bf85e6f74d9c7468cd4bcb2e7d545eae186de5e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 10 Aug 2022 23:02:54 -0500 Subject: Add ass --- runsfeed | 63 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'runsfeed') diff --git a/runsfeed b/runsfeed index 9c3b330..2068434 100755 --- a/runsfeed +++ b/runsfeed @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Run sfeed - +# shellcheck disable=2016 # set -euo pipefail main() { @@ -41,20 +41,24 @@ main() { }' logok "Generating RSS" '{ atom "$sfeedpath" >/tmp/feeds.xml && - mv /tmp/feeds.xml "$SFEED_OUTPUT/feeds.xml"; - atom "$sfeedpath" 7 >/tmp/feeds-short.xml && - mv /tmp/feeds-short.xml "$SFEED_OUTPUT/feeds-short.xml"; - }' + mv /tmp/feeds.xml "$SFEED_OUTPUT/feeds.xml"; + atom "$sfeedpath" 7 >/tmp/feeds-short.xml && + mv /tmp/feeds-short.xml "$SFEED_OUTPUT/feeds-short.xml"; + }' logok "Generating OPML" '{ opml "$sfeedrc" >/tmp/feeds.opml && mv /tmp/feeds.opml "$SFEED_OUTPUT/feeds.opml"; - }' + }' logok "Generating twtxt" '{ twtxt "$sfeedpath" >/tmp/feeds.txt && mv /tmp/feeds.txt "$SFEED_OUTPUT/feeds.txt"; - }' - # logok "Archiving old feeds" \ - # archive "$sfeedpath"/* + }' + logok "Generating ass" '{ + ass "$sfeedpath" >/tmp/feed.ass && + mv /tmp/feed.ass "$SFEED_OUTPUT/feed.ass"; + }' + logok "Archiving old feeds" \ + 'archive 60 "$sfeedpath"/*' if [ -f /tmp/runsfeed.ok ]; then echo >&2 'Done.' else @@ -106,19 +110,25 @@ update() { runcmd sfeed_update_xargs "$@" } -twtxt() { +aggregate() { curd="$PWD" cd "$1" || return 1 - if [ $# -eq 2 ]; then + if [ -n "$2" ]; then old="$(($(date +%s) - ($2 * 24 * 3600)))" else old=0 fi awk -v old="$old" \ 'BEGIN{FS="\t";OFS="\t";} int($1)>=old{$2="["FILENAME"] "$2;print}' \ - * | - sort -k1,1rn | - sfeed_twtxt + * | sort -k1,1rn +} + +ass() { + aggregate "$1" "$2" | runcmd sfeed_ass.awk +} + +twtxt() { + aggregate "$1" "$2" | sfeed_twtxt } opml() { @@ -130,26 +140,19 @@ html() { } atom() ( # atom DIRECTORY [DAYS] - curd="$PWD" - cd "$1" || return 1 - if [ $# -eq 2 ]; then - old=$(($(date +%s) - ($2 * 24 * 3600))) - else - old=0 - fi - awk -F $'\t' -v old="$old" \ - 'BEGIN{OFS="\t"} $1 && int($1)>=old{$2="["FILENAME"] "$2;print}' \ - * | - sort -k1,1rn | - sfeed_atom + aggregate "$1" "$2" | sfeed_atom ) -archive() ( # sfeed_archive FEED ... +archive() ( # sfeed_archive AGE FEED ... + age="$1" + shift + old="$sfeedpath/../sfeed.old.d" + mkdir -p "$old" for feed; do - awk -v old="$(($(date +%s) - (60 * 24 * 3600)))" \ + awk -v old="$(($(date +%s) - (age * 24 * 3600)))" \ -F '\t' 'int($1) > old' <"$feed" >"$feed.new" - mv "$feed" "$feed.old" - mv "$feed.new" "$feed" + echo mv "$feed" "$old/${feed##*/}" && + echo mv "$feed.new" "$feed" done ) -- cgit 1.4.1-21-gabe81