Files

75 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2025-06-29 09:18:39 -04:00
#!/usr/bin/bash
set -euo pipefail
MURL="https://miniflux.i.balki.me"
FID=61
2026-01-13 11:06:29 -05:00
TOKEN="${MINIFLUX_TOKEN?token missing}"
2026-01-16 17:10:35 -05:00
token_header() {
cat <<<"X-Auth-Token: $TOKEN"
}
2025-06-29 09:18:39 -04:00
process() {
local eid="$1"
local title="$2"
2025-06-29 14:25:55 -04:00
echo "Downloding content. entry: $eid title: $title"
2026-01-13 11:06:29 -05:00
# https://miniflux.app/docs/api.html#endpoint-fetch-content
2025-06-29 09:18:39 -04:00
curl --fail -o /dev/null -s "$MURL/v1/entries/$eid/fetch-content" \
--url-query update_content=true \
2026-01-16 17:10:35 -05:00
-H @<(token_header)
2025-06-29 09:18:39 -04:00
2025-06-29 14:25:55 -04:00
echo "Updating title. entry: $eid title: $title"
2026-01-13 11:06:29 -05:00
# https://miniflux.app/docs/api.html#endpoint-update-entry
2025-06-29 09:18:39 -04:00
curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \
--json "$(jo title="${title/$/✓}")" \
2026-01-16 17:10:35 -05:00
-H @<(token_header)
2025-06-29 09:18:39 -04:00
2025-06-29 14:25:55 -04:00
echo "Marking as unread. entry: $eid title: $title"
2026-01-13 11:06:29 -05:00
# https://miniflux.app/docs/api.html#endpoint-update-entries
2025-06-29 09:18:39 -04:00
curl --fail -s -X PUT "$MURL/v1/entries" \
2025-07-03 15:34:33 -04:00
--json "$(jo "entry_ids[]=$eid" status=unread)" \
2026-01-16 17:10:35 -05:00
-H @<(token_header)
2026-01-13 11:06:29 -05:00
}
filter_entries() {
# silence 'Expressions don't expand in single quotes'
# shellcheck disable=SC2016
mlr --l2n \
2026-01-16 17:10:35 -05:00
+ filter '$title =~ "\[\$\]"' \
2026-01-13 11:06:29 -05:00
+ filter -s w1="$1" -s w2="$2" '$published_at > @w2 && $published_at < @w1' \
2026-01-15 12:47:52 -05:00
+ cut -of id,title \
+ tac
2025-06-29 09:18:39 -04:00
}
main() {
local w1 w2
2026-01-13 11:06:29 -05:00
# Script will fail at the first entry that is not available yet
2026-01-16 17:10:35 -05:00
w1=$(date --iso-8601=s -d '1 week ago')
2026-01-13 11:06:29 -05:00
w2=$(date --iso-8601=s -d '5 weeks ago')
2025-06-29 09:18:39 -04:00
2025-06-29 14:25:55 -04:00
echo "Considering articles between w2: $w2 and w1: $w1 "
2025-06-29 09:18:39 -04:00
2026-01-13 11:06:29 -05:00
# https://miniflux.app/docs/api.html#endpoint-get-feed-entries
2025-06-29 14:25:55 -04:00
curl -s --fail "$MURL/v1/feeds/$FID/entries" \
2026-01-13 11:06:29 -05:00
--url-query limit=150 \
2025-06-29 09:18:39 -04:00
--url-query order=id \
2026-01-15 12:47:52 -05:00
--url-query direction=desc \
2026-01-16 17:10:35 -05:00
-H @<(token_header) |
2026-01-15 12:47:52 -05:00
yq -pj -oj '.entries[]' |
2026-01-13 11:06:29 -05:00
filter_entries "$w1" "$w2" |
2025-07-04 19:19:36 -04:00
while read -r eid title; do
echo "processing entry: $eid title: $title"
process "$eid" "$title"
done
2025-06-29 09:18:39 -04:00
}
main