cleanup and improve

This commit is contained in:
2026-01-13 11:06:29 -05:00
parent 6e2131c1c2
commit 02065089e1

46
run.sh
View File

@@ -5,49 +5,61 @@ set -euo pipefail
MURL="https://miniflux.i.balki.me" MURL="https://miniflux.i.balki.me"
FID=61 FID=61
TOKEN="${MINIFLUX_TOKEN?token missing}"
process() { process() {
local eid="$1" local eid="$1"
local title="$2" local title="$2"
echo "Downloding content. entry: $eid title: $title" echo "Downloding content. entry: $eid title: $title"
# https://miniflux.app/docs/api.html#endpoint-fetch-content
curl --fail -o /dev/null -s "$MURL/v1/entries/$eid/fetch-content" \ curl --fail -o /dev/null -s "$MURL/v1/entries/$eid/fetch-content" \
--url-query update_content=true \ --url-query update_content=true \
-H "X-Auth-Token: $MINIFLUX_TOKEN" -H "X-Auth-Token: $TOKEN"
echo "Updating title. entry: $eid title: $title" echo "Updating title. entry: $eid title: $title"
# https://miniflux.app/docs/api.html#endpoint-update-entry
curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \ curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \
--json "$(jo title="${title/$/✓}")" \ --json "$(jo title="${title/$/✓}")" \
-H "X-Auth-Token: $MINIFLUX_TOKEN" -H "X-Auth-Token: $TOKEN"
echo "Marking as unread. entry: $eid title: $title" echo "Marking as unread. entry: $eid title: $title"
# https://miniflux.app/docs/api.html#endpoint-update-entries
curl --fail -s -X PUT "$MURL/v1/entries" \ curl --fail -s -X PUT "$MURL/v1/entries" \
--json "$(jo "entry_ids[]=$eid" status=unread)" \ --json "$(jo "entry_ids[]=$eid" status=unread)" \
-H "X-Auth-Token: $MINIFLUX_TOKEN" -H "X-Auth-Token: $TOKEN"
}
filter_entries() {
# silence 'Expressions don't expand in single quotes'
# shellcheck disable=SC2016
mlr --l2n \
filter '$title =~ "\[\$\]"' \
+ filter -s w1="$1" -s w2="$2" '$published_at > @w2 && $published_at < @w1' \
+ cut -of id,title
} }
main() { main() {
local w1 w2 local w1 w2
if [ "$(date +%A)" = Thursday ]; then # Script will fail at the first entry that is not available yet
w1=$(date --iso-8601=s -d 'last thursday') w1=$(date --iso-8601=s -d '2 weeks ago')
else w2=$(date --iso-8601=s -d '5 weeks ago')
w1=$(date --iso-8601=s -d 'last thursday -1 week')
fi
w2=$(date --iso-8601=s -d '3 weeks ago')
echo "Considering articles between w2: $w2 and w1: $w1 " echo "Considering articles between w2: $w2 and w1: $w1 "
# https://miniflux.app/docs/api.html#endpoint-get-feed-entries
curl -s --fail "$MURL/v1/feeds/$FID/entries" \ curl -s --fail "$MURL/v1/feeds/$FID/entries" \
--url-query limit=50 \ --url-query limit=150 \
--url-query order=id \ --url-query order=id \
--url-query direction=desc \ --url-query direction=asc \
-H "X-Auth-Token: $MINIFLUX_TOKEN" | -H "X-Auth-Token: $TOKEN" |
yq '.entries[]' | yq '.entries[]' |
mlr --l2n \ filter_entries "$w1" "$w2" |
filter '$title =~ "\[\$\]"' \
'then' filter -s w1="$w1" -s w2="$w2" '$published_at > @w2 && $published_at < @w1' \
'then' cut -of id,title |
while read -r eid title; do while read -r eid title; do
echo "processing entry: $eid title: $title" echo "processing entry: $eid title: $title"
process "$eid" "$title" process "$eid" "$title"