derstandard: mark items as seen on display, auto-prune at 200

- items command now marks ALL returned URLs as seen (not just fetched)
- Auto-prunes seen file to 200 entries (removes oldest)
This commit is contained in:
Agent 2026-02-03 22:04:57 +00:00
parent 252fcb3ad0
commit dbca7fc17d
2 changed files with 20 additions and 1 deletions

View file

@ -57,6 +57,15 @@ mark_seen() {
fi
}
prune_seen() {
# Keep only last 200 entries
local count=$(wc -l < "$SEEN_FILE" 2>/dev/null | tr -d ' ')
if [ "$count" -gt 200 ]; then
local excess=$((count - 200))
tail -200 "$SEEN_FILE" > "${SEEN_FILE}.tmp" && mv "${SEEN_FILE}.tmp" "$SEEN_FILE"
fi
}
is_seen() {
grep -qF "$1" "$SEEN_FILE" 2>/dev/null
}
@ -74,16 +83,21 @@ case "${1:-}" in
feed=$(fetch_feed "$max")
# Build items list
# Build items list, mark all as seen, only display unseen (unless --all)
while IFS=$'\t' read -r title url; do
if $show_all || ! is_seen "$url"; then
printf '%s\t%s\n' "$title" "$url"
fi
# Mark as seen regardless of display
mark_seen "$url"
done < <(
titles=$(echo "$feed" | grep -oP '<title>\K[^<]+' | tail -n +2 | decode_entities)
urls=$(echo "$feed" | grep -oP '<link>\K[^<]+' | grep "derstandard.at/story")
paste <(echo "$titles") <(echo "$urls") 2>/dev/null | head -"$max"
)
# Prune to max 200 entries
prune_seen
;;
article)
[ -z "${2:-}" ] && { echo "Usage: derstandard article <url>"; exit 1; }
@ -102,6 +116,7 @@ case "${1:-}" in
# Mark as seen
mark_seen "$url"
done
prune_seen
;;
urls)
fetch_feed "${2:-50}" | grep -oP '<link>\K[^<]+' | grep "derstandard.at/story"

View file

@ -1 +1,5 @@
https://www.derstandard.at/story/3000000306979/trump-always-chickens-out-macht-taco-tatsaechlich-immer-einen-rueckzieher?ref=rss
https://www.derstandard.at/story/3000000307063/usa-schiessen-iranische-drohne-nahe-flugzeugtraeger-im-arabischen-meer-ab?ref=rss
https://www.derstandard.at/story/3000000306672/neue-epstein-files-werfen-fragen-an-adelige-diplomaten-und-eva-dichand-auf?ref=rss
https://www.derstandard.at/story/3000000306965/wodurch-fast-vier-von-zehn-krebsfaellen-vermeidbar-waeren?ref=rss
https://www.derstandard.at/story/3000000306903/etappensieg-fuer-saudischen-staatsfonds-mubadala-im-streit-mit-signa?ref=rss