Files
miniflux_lwn/run.sh
Balakrishnan Balasubramanian 13a79f0d34 Fix Quoting problem in title
Add jo as dependency. Fix crash with below title
[$] Libxml2's "no security embargoes" policy Updates
2025-07-03 09:35:46 -04:00

61 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/bash
set -euo pipefail
MURL="https://miniflux.i.balki.me"
FID=61
process() {
local eid="$1"
local title="$2"
echo "Downloding content. entry: $eid title: $title"
curl --fail -o /dev/null -s "$MURL/v1/entries/$eid/fetch-content" \
--url-query update_content=true \
-H "X-Auth-Token: $MINIFLUX_TOKEN"
echo "Updating title. entry: $eid title: $title"
curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \
--json "$(jo title="${title/$/✓}")" \
-H "X-Auth-Token: $MINIFLUX_TOKEN"
echo "Marking as unread. entry: $eid title: $title"
curl --fail -s -X PUT "$MURL/v1/entries" \
--json "$(jo entry_ids="$(jo -a "$eid")" status=unread)" \
-H "X-Auth-Token: $MINIFLUX_TOKEN"
}
main() {
local w1 w2
if [ "$(date +%A)" = Thursday ]; then
w1=$(date --iso-8601=s -d 'last thursday')
else
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 "
curl -s --fail "$MURL/v1/feeds/$FID/entries" \
--url-query limit=50 \
--url-query order=id \
--url-query direction=desc \
-H "X-Auth-Token: $MINIFLUX_TOKEN" |
yq '.entries[]' |
mlr --l2n \
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
echo "processing entry: $eid title: $title"
process "$eid" "$title"
done
}
main