commit 6d5eb310c533fc1376a1ad321502bb8a84a476a3 Author: Balakrishnan Balasubramanian Date: Sun Jun 29 09:18:39 2025 -0400 initial commit diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..0a7c088 --- /dev/null +++ b/run.sh @@ -0,0 +1,59 @@ +#!/usr/bin/bash + +set -euo pipefail + +MURL="https://miniflux.i.balki.me" +FID=61 + +process() { + local eid="$1" + local title="$2" + + echo "processing entry: $eid title: $title" + + 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" + + curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \ + --json "$(printf '{"title":"%s"}' "$title")" \ + -H "X-Auth-Token: $MINIFLUX_TOKEN" + + curl --fail -s -X PUT "$MURL/v1/entries" \ + --json "$(printf '{"entry_ids":[%s],"status":"unread"}' "$eid")" \ + -H "X-Auth-Token: $MINIFLUX_TOKEN" + +} + +main() { + + local w1 w2 + + if [ "$(date +%u)" = 4 ]; 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 "w1: $w1 w2: $w2" + + curl -s --fail -D headers.out "$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 --l2p --ho \ + 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 + process "$eid" "$title" + done + +} + +main